Class SimpleHttpRequest
- java.lang.Object
-
- org.apache.hc.core5.http.message.HeaderGroup
-
- org.apache.hc.core5.http.message.BasicHttpRequest
-
- org.apache.hc.client5.http.async.methods.ConfigurableHttpRequest
-
- org.apache.hc.client5.http.async.methods.SimpleHttpRequest
-
- All Implemented Interfaces:
java.io.Serializable,Configurable,org.apache.hc.core5.http.HttpMessage,org.apache.hc.core5.http.HttpRequest,org.apache.hc.core5.http.MessageHeaders
public final class SimpleHttpRequest extends ConfigurableHttpRequest
HTTP request that can enclose a body represented as a simple text string or an array of bytes.IMPORTANT:
SimpleHttpRequests are intended for simple scenarios where entities inclosed in requests are known to be small. It is generally recommended to useAsyncRequestBuilderand streamingAsyncEntityProducers.- Since:
- 5.0
- See Also:
SimpleBody,AsyncRequestBuilder,AsyncEntityProducer, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private SimpleBodybodyprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description SimpleHttpRequest(java.lang.String method, java.lang.String path)Constructs a new request message with the given method and request path.SimpleHttpRequest(java.lang.String method, java.lang.String scheme, org.apache.hc.core5.net.URIAuthority authority, java.lang.String path)Constructs a new request message with the given method, scheme, authority, and request path.SimpleHttpRequest(java.lang.String method, java.net.URI requestUri)Constructs a new request message with the given method, and request URI.SimpleHttpRequest(java.lang.String method, org.apache.hc.core5.http.HttpHost host, java.lang.String path)Constructs a new request message with the given method, host, and request path.SimpleHttpRequest(org.apache.hc.core5.http.Method method, java.net.URI requestUri)Constructs a new request message with the given method, and request URI.SimpleHttpRequest(org.apache.hc.core5.http.Method method, org.apache.hc.core5.http.HttpHost host, java.lang.String path)Constructs a new request message with the given method, host, and request path.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static SimpleHttpRequestcopy(org.apache.hc.core5.http.HttpRequest original)Deprecated.static SimpleHttpRequestcreate(java.lang.String method, java.lang.String uri)Creates a new request message with the given method and request path.static SimpleHttpRequestcreate(java.lang.String method, java.lang.String scheme, org.apache.hc.core5.net.URIAuthority authority, java.lang.String path)Creates a new request message with the given method, scheme, authority, and request path.static SimpleHttpRequestcreate(java.lang.String method, java.net.URI uri)Creates a new request message with the given method and request path.static SimpleHttpRequestcreate(org.apache.hc.core5.http.Method method, java.net.URI uri)Creates a new request message with the given method and request path.static SimpleHttpRequestcreate(org.apache.hc.core5.http.Method method, org.apache.hc.core5.http.HttpHost host, java.lang.String path)Creates a new request message with the given method, host, and request path.SimpleBodygetBody()Gets the request body.byte[]getBodyBytes()Gets the request body as a byte array.java.lang.StringgetBodyText()Gets the request body as a String.org.apache.hc.core5.http.ContentTypegetContentType()Gets the request content type.voidsetBody(byte[] bodyBytes, org.apache.hc.core5.http.ContentType contentType)Sets the message body and content type.voidsetBody(java.lang.String bodyText, org.apache.hc.core5.http.ContentType contentType)Sets the message body and content type.voidsetBody(SimpleBody body)Sets the message body and content type.-
Methods inherited from class org.apache.hc.client5.http.async.methods.ConfigurableHttpRequest
getConfig, setConfig
-
Methods inherited from class org.apache.hc.core5.http.message.BasicHttpRequest
addHeader, getAuthority, getMethod, getPath, getRequestUri, getScheme, getUri, getVersion, setAbsoluteRequestUri, setAuthority, setHeader, setPath, setScheme, setUri, setVersion, toString
-
Methods inherited from class org.apache.hc.core5.http.message.HeaderGroup
addHeader, clear, containsHeader, countHeaders, getCondensedHeader, getFirstHeader, getHeader, getHeaders, getHeaders, getLastHeader, headerIterator, headerIterator, removeHeader, removeHeaders, removeHeaders, setHeader, setHeaders
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
body
private SimpleBody body
-
-
Constructor Detail
-
SimpleHttpRequest
public SimpleHttpRequest(java.lang.String method, java.lang.String path)Constructs a new request message with the given method and request path.- Parameters:
method- request method.path- request path.
-
SimpleHttpRequest
public SimpleHttpRequest(java.lang.String method, org.apache.hc.core5.http.HttpHost host, java.lang.String path)Constructs a new request message with the given method, host, and request path.- Parameters:
method- request method.host- request host.path- request path.
-
SimpleHttpRequest
public SimpleHttpRequest(java.lang.String method, java.net.URI requestUri)Constructs a new request message with the given method, and request URI.- Parameters:
method- request method.requestUri- request URI.- Since:
- 5.1
-
SimpleHttpRequest
public SimpleHttpRequest(org.apache.hc.core5.http.Method method, java.net.URI requestUri)Constructs a new request message with the given method, and request URI.- Parameters:
method- request method.requestUri- request URI.- Since:
- 5.1
-
SimpleHttpRequest
public SimpleHttpRequest(org.apache.hc.core5.http.Method method, org.apache.hc.core5.http.HttpHost host, java.lang.String path)Constructs a new request message with the given method, host, and request path.- Parameters:
method- request method.host- request host.path- request path.- Since:
- 5.1
-
SimpleHttpRequest
public SimpleHttpRequest(java.lang.String method, java.lang.String scheme, org.apache.hc.core5.net.URIAuthority authority, java.lang.String path)Constructs a new request message with the given method, scheme, authority, and request path.- Parameters:
method- request method.scheme- request host.authority- request URI authority.path- request path.- Since:
- 5.1
-
-
Method Detail
-
create
public static SimpleHttpRequest create(java.lang.String method, java.lang.String uri)
Creates a new request message with the given method and request path.- Parameters:
method- request method.uri- request URI.- Returns:
- a new SimpleHttpRequest.
- Since:
- 5.1
-
create
public static SimpleHttpRequest create(java.lang.String method, java.net.URI uri)
Creates a new request message with the given method and request path.- Parameters:
method- request method.uri- request URI.- Returns:
- a new SimpleHttpRequest.
- Since:
- 5.1
-
create
public static SimpleHttpRequest create(org.apache.hc.core5.http.Method method, java.net.URI uri)
Creates a new request message with the given method and request path.- Parameters:
method- request method.uri- request URI.- Returns:
- a new SimpleHttpRequest.
- Since:
- 5.1
-
create
public static SimpleHttpRequest create(org.apache.hc.core5.http.Method method, org.apache.hc.core5.http.HttpHost host, java.lang.String path)
Creates a new request message with the given method, host, and request path.- Parameters:
method- request method.host- request host.path- request path.- Returns:
- a new SimpleHttpRequest.
- Since:
- 5.1
-
create
public static SimpleHttpRequest create(java.lang.String method, java.lang.String scheme, org.apache.hc.core5.net.URIAuthority authority, java.lang.String path)
Creates a new request message with the given method, scheme, authority, and request path.- Parameters:
method- request method.scheme- request host.authority- request URI authority.path- request path.- Returns:
- a new SimpleHttpRequest.
- Since:
- 5.1
-
copy
@Deprecated public static SimpleHttpRequest copy(org.apache.hc.core5.http.HttpRequest original)
Deprecated.Copies the given HttpRequest.- Parameters:
original- the source to copy.- Returns:
- a new SimpleHttpRequest.
-
setBody
public void setBody(SimpleBody body)
Sets the message body and content type.- Parameters:
body- request body.
-
setBody
public void setBody(byte[] bodyBytes, org.apache.hc.core5.http.ContentType contentType)Sets the message body and content type.- Parameters:
bodyBytes- request body.contentType- request content type.
-
setBody
public void setBody(java.lang.String bodyText, org.apache.hc.core5.http.ContentType contentType)Sets the message body and content type.- Parameters:
bodyText- request body.contentType- request content type.
-
getBody
public SimpleBody getBody()
Gets the request body.- Returns:
- the request body.
-
getContentType
public org.apache.hc.core5.http.ContentType getContentType()
Gets the request content type.- Returns:
- the request content type.
-
getBodyText
public java.lang.String getBodyText()
Gets the request body as a String.- Returns:
- the request body.
-
getBodyBytes
public byte[] getBodyBytes()
Gets the request body as a byte array.- Returns:
- the request body.
-
-