public class HTTPRequestBuilder
extends java.lang.Object
HTTPRequest
. This helps construct different types of httpRequests.Constructor | Description |
---|---|
HTTPRequestBuilder() |
Creates a new HTTPRequestBuilder object.
|
HTTPRequestBuilder(java.net.URL url) |
Creates a new HTTPRequestBuilder object from a
URL . |
Modifier and Type | Method | Description |
---|---|---|
HTTPRequestBuilder |
appendQuery(java.lang.String key,
java.lang.String value) |
Adds a query key/value to this
HTTPRequestBuilder . |
ClientHTTPRequest |
buildClientHTTPRequest() |
|
HTTPAddress |
buildHTTPAddress() |
Builds an
HTTPAddress object from the set host/port name. |
HTTPRequest |
buildHTTPRequest() |
Builds an Immutable
HTTPRequest object that can be used to send a request. |
HTTPRequestBuilder |
duplicate() |
Creates an independent copy of this
HTTPRequestBuilder . |
HTTPRequestBuilder |
removeHeader(java.lang.String key) |
Removes a header on the HTTPRequest.
|
HTTPRequestBuilder |
removeQuery(java.lang.String key) |
Removes a Key from the query portion of the http request.
|
HTTPRequestBuilder |
replaceHTTPHeaders(HTTPHeaders hh) |
Replaces all the
HTTPHeaders for this HTTPRequestBuilder with the ones provided. |
HTTPRequestBuilder |
setBody(java.lang.String str) |
|
HTTPRequestBuilder |
setBody(java.lang.String str,
java.nio.charset.Charset cs) |
|
HTTPRequestBuilder |
setBody(java.nio.ByteBuffer bb) |
|
HTTPRequestBuilder |
setHeader(java.lang.String key,
java.lang.String value) |
Set a header on the HTTPRequest.
|
HTTPRequestBuilder |
setHost(java.lang.String host) |
Sets the Host: header in the client.
|
HTTPRequestBuilder |
setHost(java.lang.String host,
boolean setHeader) |
Sets the Host: header in the client.
|
HTTPRequestBuilder |
setHTTPAddress(HTTPAddress ha,
boolean setHostHeader) |
Sets the
HTTPAddress for this builder. |
HTTPRequestBuilder |
setHTTPRequestHeader(HTTPRequestHeader hrh) |
Set the
HTTPRequestHeader object for this HTTPRequestBuilder. |
HTTPRequestBuilder |
setHTTPVersion(java.lang.String version) |
Set the HTTPVersion for this HTTPRequestBuilder.
|
HTTPRequestBuilder |
setPath(java.lang.String path) |
This sets the request path for the
HTTPRequestBuilder . |
HTTPRequestBuilder |
setPort(int port) |
This sets the port to use in the
buildHTTPAddress() method. |
HTTPRequestBuilder |
setQueryString(java.lang.String query) |
Set the query on this
HTTPRequestBuilder . |
HTTPRequestBuilder |
setRequestMethod(java.lang.String rm) |
Sets the
HTTPRequestMethod for this request. |
HTTPRequestBuilder |
setRequestMethod(HTTPRequestMethod rm) |
Sets the
HTTPRequestMethod for this request. |
HTTPRequestBuilder |
setSSL(boolean doSSL) |
Sets if the request should be made using ssl or not.
|
HTTPRequestBuilder |
setTimeout(long size,
java.util.concurrent.TimeUnit unit) |
|
HTTPRequestBuilder |
setURL(java.net.URL url) |
Uses a
URL to set the path and query on this HTTPRequestBuilder object. |
public HTTPRequestBuilder()
public HTTPRequestBuilder(java.net.URL url)
URL
. The Path and query will be set from it.url
- the URL
to use to create the HTTPRequestBuilder
object with.public HTTPRequestBuilder setURL(java.net.URL url)
URL
to set the path and query on this HTTPRequestBuilder object.url
- the URL
to use to set.HTTPRequestBuilder
object.public HTTPRequestBuilder setHTTPRequestHeader(HTTPRequestHeader hrh)
HTTPRequestHeader
object for this HTTPRequestBuilder.hrh
- the HTTPRequestHeader
object to set.HTTPRequestBuilder
object.public HTTPRequestBuilder setRequestMethod(java.lang.String rm)
HTTPRequestMethod
for this request. This will accept non-stander strings in the for the request.rm
- the http request method to set this request too.HTTPRequestBuilder
object.public HTTPRequestBuilder setHTTPVersion(java.lang.String version)
version
- the HttpVersion to setHTTPRequestBuilder
object.public HTTPRequestBuilder setPath(java.lang.String path)
HTTPRequestBuilder
. If a query is on this path it will replace the current query
in this builder.path
- the path to set.HTTPRequestBuilder
object.public HTTPRequestBuilder setQueryString(java.lang.String query)
HTTPRequestBuilder
. If there are currently any query params they will be removed before this is set.query
- the query string to set.HTTPRequestBuilder
object.public HTTPRequestBuilder appendQuery(java.lang.String key, java.lang.String value)
HTTPRequestBuilder
. Duplicate keys can be added.key
- the query key to set.value
- the query value for the set key.HTTPRequestBuilder
object.public HTTPRequestBuilder removeQuery(java.lang.String key)
key
- the Key to removeHTTPRequestBuilder
object.public HTTPRequestBuilder setHTTPAddress(HTTPAddress ha, boolean setHostHeader)
HTTPAddress
for this builder. This will add a Host header into the headers of this builder
when this object it built. This is also used with the buildHTTPAddress()
method.ha
- the HTTPAddress
to be set.setHostHeader
- true if you want to chage the Host header to the host in the HTTPAddress, false if you do not.HTTPRequestBuilder
object.public HTTPRequestBuilder setHost(java.lang.String host)
buildHTTPAddress()
method.
Setting to null will remove this header.
NOTE: this will override the HTTP Host header.host
- the host name or ip to set.HTTPRequestBuilder
object.public HTTPRequestBuilder setHost(java.lang.String host, boolean setHeader)
buildHTTPAddress()
method.
Setting to null will remove this header.host
- the host name or ip to set.setHeader
- lets you choose if you want to set the host header as well. Set to false if you want to have a different
HTTPAddress host then whats in the http host header.HTTPRequestBuilder
object.public HTTPRequestBuilder setSSL(boolean doSSL)
doSSL
- true
if ssl should be used.HTTPRequestBuilder
object.public HTTPRequestBuilder setPort(int port)
buildHTTPAddress()
method. If not set the default port
for the protocol type (http or https) will be used.port
- port number to set.HTTPRequestBuilder
object.public HTTPRequestBuilder setBody(java.nio.ByteBuffer bb)
public HTTPRequestBuilder setBody(java.lang.String str)
public HTTPRequestBuilder setBody(java.lang.String str, java.nio.charset.Charset cs)
public HTTPRequestBuilder setTimeout(long size, java.util.concurrent.TimeUnit unit)
public HTTPRequestBuilder duplicate()
HTTPRequestBuilder
.HTTPRequestBuilder
object with all the same values set.public HTTPRequestBuilder setHeader(java.lang.String key, java.lang.String value)
key
- the key for the header.value
- the value in the header.HTTPRequestBuilder
object.public HTTPRequestBuilder removeHeader(java.lang.String key)
key
- the key for the header to remove.HTTPRequestBuilder
object.public HTTPRequestBuilder replaceHTTPHeaders(HTTPHeaders hh)
HTTPHeaders
for this HTTPRequestBuilder with the ones provided.hh
- the HTTPHeaders
object to set.HTTPRequestBuilder
object.public HTTPRequestBuilder setRequestMethod(HTTPRequestMethod rm)
HTTPRequestMethod
for this request. This uses the standard http request methods enum.rm
- the http request method to set this request too.HTTPRequestBuilder
object.public HTTPAddress buildHTTPAddress()
HTTPAddress
object from the set host/port name.HTTPAddress
object with host/port/ssl arguments set.public ClientHTTPRequest buildClientHTTPRequest()
public HTTPRequest buildHTTPRequest()
HTTPRequest
object that can be used to send a request.HTTPRequest
object