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:
Serializable, Configurable, org.apache.hc.core5.http.HttpMessage, org.apache.hc.core5.http.HttpRequest, org.apache.hc.core5.http.MessageHeaders
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 use
AsyncRequestBuilder and streaming
AsyncEntityProducers.
- Since:
- 5.0
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSimpleHttpRequest(String method, String path) Constructs a new request message with the given method and request path.SimpleHttpRequest(String method, String scheme, org.apache.hc.core5.net.URIAuthority authority, String path) Constructs a new request message with the given method, scheme, authority, and request path.SimpleHttpRequest(String method, URI requestUri) Constructs a new request message with the given method, and request URI.SimpleHttpRequest(String method, org.apache.hc.core5.http.HttpHost host, String path) Constructs a new request message with the given method, host, and request path.SimpleHttpRequest(org.apache.hc.core5.http.Method method, 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, String path) Constructs a new request message with the given method, host, and request path. -
Method Summary
Modifier and TypeMethodDescriptionstatic SimpleHttpRequestcopy(org.apache.hc.core5.http.HttpRequest original) Deprecated.static SimpleHttpRequestCreates a new request message with the given method and request path.static SimpleHttpRequestCreates a new request message with the given method, scheme, authority, and request path.static SimpleHttpRequestCreates a new request message with the given method and request path.static SimpleHttpRequestCreates a new request message with the given method and request path.static SimpleHttpRequestCreates a new request message with the given method, host, and request path.getBody()Gets the request body.byte[]Gets the request body as a byte array.Gets the request body as a String.org.apache.hc.core5.http.ContentTypeGets the request content type.voidsetBody(byte[] bodyBytes, org.apache.hc.core5.http.ContentType contentType) Sets the message body and content type.voidSets the message body and content type.voidsetBody(SimpleBody body) Sets the message body and content type.Methods inherited from class ConfigurableHttpRequest
getConfig, setConfigMethods 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, toStringMethods 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, setHeadersMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.hc.core5.http.HttpMessage
addHeader, removeHeader, removeHeaders, setHeader, setHeadersMethods inherited from interface org.apache.hc.core5.http.MessageHeaders
containsHeader, countHeaders, getFirstHeader, getHeader, getHeaders, getHeaders, getLastHeader, headerIterator, headerIterator
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
body
-
-
Constructor Details
-
SimpleHttpRequest
-
SimpleHttpRequest
-
SimpleHttpRequest
-
SimpleHttpRequest
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, 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(String method, String scheme, org.apache.hc.core5.net.URIAuthority authority, 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 Details
-
create
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
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
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, 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(String method, String scheme, org.apache.hc.core5.net.URIAuthority authority, 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.Copies the given HttpRequest.- Parameters:
original- the source to copy.- Returns:
- a new SimpleHttpRequest.
-
setBody
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
Sets the message body and content type.- Parameters:
bodyText- request body.contentType- request content type.
-
getBody
-
getContentType
public org.apache.hc.core5.http.ContentType getContentType()Gets the request content type.- Returns:
- the request content type.
-
getBodyText
-
getBodyBytes
public byte[] getBodyBytes()Gets the request body as a byte array.- Returns:
- the request body.
-
SimpleRequestBuilder