public static class HttpRequest.Builder extends Object
Constructor and Description |
---|
HttpRequest.Builder(ActorRef<? super WebMessage> from) |
HttpRequest.Builder(ActorRef<? super WebMessage> from,
ByteBuffer body) |
HttpRequest.Builder(ActorRef<? super WebMessage> from,
String body) |
Modifier and Type | Method and Description |
---|---|
HttpRequest.Builder |
addCookie(Cookie cookie)
Adds the specified cookie to the request.
|
HttpRequest.Builder |
addHeader(String name,
String value)
Adds a request header with the given name and value.
|
HttpRequest.Builder |
addParam(String name,
String value)
Adds a request parameter with the given name and value.
|
HttpRequest |
build()
Instantiates a new immutable
HttpRequest based on the values set in this builder. |
HttpRequest.Builder |
setCharacterEncoding(Charset charset)
Sets the character encoding (MIME charset) of the response being sent to the client, for example,
UTF-8 . |
HttpRequest.Builder |
setContentType(String contentType)
Sets the content type of the request being sent to the client.
|
HttpRequest.Builder |
setMethod(String method) |
HttpRequest.Builder |
setPath(String path) |
HttpRequest.Builder |
setPort(int port) |
HttpRequest.Builder |
setScheme(String scheme) |
HttpRequest.Builder |
setServer(String server) |
HttpRequest.Builder |
setSourceHost(String sourceAddress) |
HttpRequest.Builder |
setSourcePort(int sourcePort) |
public HttpRequest.Builder(ActorRef<? super WebMessage> from, String body)
public HttpRequest.Builder(ActorRef<? super WebMessage> from, ByteBuffer body)
public HttpRequest.Builder(ActorRef<? super WebMessage> from)
public HttpRequest.Builder setSourceHost(String sourceAddress)
public HttpRequest.Builder setSourcePort(int sourcePort)
public HttpRequest.Builder setContentType(String contentType)
Sets the content type of the request being sent to the client.
The given content type may include a character encoding specification, for example,text/html;charset=UTF-8
. The Content-Type
header is used to communicate the content type and the character encoding used in the response writer to the clientcontentType
- the MIME type of the contentpublic HttpRequest.Builder setCharacterEncoding(Charset charset)
Sets the character encoding (MIME charset) of the response being sent to the client, for example, UTF-8
. If the character encoding has already been set by setContentType(java.lang.String)
, this method overrides it. Calling setContentType(java.lang.String)
with "text/html"
and calling this method with Charset.forName("UTF-8")
is equivalent with calling setContentType
with "text/html; charset=UTF-8"
.
charset
- only the character sets defined by IANA Character Sets (http://www.iana.org/assignments/character-sets)setContentType(java.lang.String)
public HttpRequest.Builder addHeader(String name, String value)
Adds a request header with the given name and value. This method allows response headers to have multiple values.
name
- the name of the headervalue
- the additional header value. If it contains octet string, it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)public HttpRequest.Builder addCookie(Cookie cookie)
Adds the specified cookie to the request. This method can be called multiple times to set multiple cookies.
cookie
- the Cookie
to return to the clientthis
public HttpRequest.Builder setMethod(String method)
public HttpRequest.Builder setScheme(String scheme)
public HttpRequest.Builder setServer(String server)
public HttpRequest.Builder setPort(int port)
public HttpRequest.Builder setPath(String path)
public HttpRequest.Builder addParam(String name, String value)
Adds a request parameter with the given name and value.
name
- the name of the parametervalue
- the additional header value. If it contains octet string, it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)public HttpRequest build()
Instantiates a new immutable HttpRequest
based on the values set in this builder.
HttpRequest