public final class SimpleHttpRequest extends ConfigurableHttpRequest
IMPORTANT: SimpleHttpRequest
s are intended for simple scenarios where entities inclosed
in requests are known to be small. It is generally recommended to use
AsyncRequestBuilder
and streaming
AsyncEntityProducer
s.
SimpleBody
,
AsyncRequestBuilder
,
AsyncEntityProducer
,
Serialized FormConstructor and Description |
---|
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.
|
SimpleHttpRequest(org.apache.hc.core5.http.Method 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(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.
|
Modifier and Type | Method and Description |
---|---|
static SimpleHttpRequest |
copy(org.apache.hc.core5.http.HttpRequest original)
Deprecated.
|
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.
|
static SimpleHttpRequest |
create(org.apache.hc.core5.http.Method method,
URI uri)
Creates a new request message with the given method and request path.
|
static SimpleHttpRequest |
create(String method,
String uri)
Creates a new request message with the given method and request path.
|
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.
|
static SimpleHttpRequest |
create(String method,
URI uri)
Creates a new request message with the given method and request path.
|
SimpleBody |
getBody()
Gets the request body.
|
byte[] |
getBodyBytes()
Gets the request body as a byte array.
|
String |
getBodyText()
Gets the request body as a String.
|
org.apache.hc.core5.http.ContentType |
getContentType()
Gets the request content type.
|
void |
setBody(byte[] bodyBytes,
org.apache.hc.core5.http.ContentType contentType)
Sets the message body and content type.
|
void |
setBody(SimpleBody body)
Sets the message body and content type.
|
void |
setBody(String bodyText,
org.apache.hc.core5.http.ContentType contentType)
Sets the message body and content type.
|
getConfig, setConfig
addHeader, getAuthority, getMethod, getPath, getRequestUri, getScheme, getUri, getVersion, setAbsoluteRequestUri, setAuthority, setHeader, setPath, setScheme, setUri, setVersion, toString
addHeader, clear, containsHeader, countHeaders, getCondensedHeader, getFirstHeader, getHeader, getHeaders, getHeaders, getLastHeader, headerIterator, headerIterator, removeHeader, removeHeaders, removeHeaders, setHeader, setHeaders
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public SimpleHttpRequest(String method, String path)
method
- request method.path
- request path.public SimpleHttpRequest(String method, org.apache.hc.core5.http.HttpHost host, String path)
method
- request method.host
- request host.path
- request path.public SimpleHttpRequest(String method, URI requestUri)
method
- request method.requestUri
- request URI.public SimpleHttpRequest(org.apache.hc.core5.http.Method method, URI requestUri)
method
- request method.requestUri
- request URI.public SimpleHttpRequest(org.apache.hc.core5.http.Method method, org.apache.hc.core5.http.HttpHost host, String path)
method
- request method.host
- request host.path
- request path.public SimpleHttpRequest(String method, String scheme, org.apache.hc.core5.net.URIAuthority authority, String path)
method
- request method.scheme
- request host.authority
- request URI authority.path
- request path.public static SimpleHttpRequest create(String method, String uri)
method
- request method.uri
- request URI.public static SimpleHttpRequest create(String method, URI uri)
method
- request method.uri
- request URI.public static SimpleHttpRequest create(org.apache.hc.core5.http.Method method, URI uri)
method
- request method.uri
- request URI.public static SimpleHttpRequest create(org.apache.hc.core5.http.Method method, org.apache.hc.core5.http.HttpHost host, String path)
method
- request method.host
- request host.path
- request path.public static SimpleHttpRequest create(String method, String scheme, org.apache.hc.core5.net.URIAuthority authority, String path)
method
- request method.scheme
- request host.authority
- request URI authority.path
- request path.@Deprecated public static SimpleHttpRequest copy(org.apache.hc.core5.http.HttpRequest original)
SimpleRequestBuilder
original
- the source to copy.public void setBody(SimpleBody body)
body
- request body.public void setBody(byte[] bodyBytes, org.apache.hc.core5.http.ContentType contentType)
bodyBytes
- request body.contentType
- request content type.public void setBody(String bodyText, org.apache.hc.core5.http.ContentType contentType)
bodyText
- request body.contentType
- request content type.public SimpleBody getBody()
public org.apache.hc.core5.http.ContentType getContentType()
public String getBodyText()
public byte[] getBodyBytes()
Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.