public static class Http.RequestBuilder
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected play.api.mvc.Request<Http.RequestBody> |
req |
Constructor and Description |
---|
RequestBuilder()
Returns a simple request builder.
|
RequestBuilder(play.api.mvc.request.RequestFactory requestFactory)
Returns a simple request builder.
|
Modifier and Type | Method and Description |
---|---|
<T> Http.RequestBuilder |
attr(TypedKey<T> key,
T value)
Add an attribute to the request.
|
TypedMap |
attrs()
Get the request attributes.
|
Http.RequestBuilder |
attrs(TypedMap newAttrs)
Update the request attributes.
|
Http.RequestBody |
body() |
protected Http.RequestBuilder |
body(Http.RequestBody body)
Set the body of the request.
|
protected Http.RequestBuilder |
body(Http.RequestBody body,
java.lang.String contentType)
Set the body of the request.
|
Http.RequestBuilder |
bodyForm(java.util.Map<java.lang.String,java.lang.String> data)
Set a Form url encoded body to this request.
|
Http.RequestBuilder |
bodyFormArrayValues(java.util.Map<java.lang.String,java.lang.String[]> data)
Set a Form url encoded body to this request.
|
Http.RequestBuilder |
bodyJson(com.fasterxml.jackson.databind.JsonNode node)
Set a Json Body to this request.
|
Http.RequestBuilder |
bodyJson(play.api.libs.json.JsValue json)
Set a Json Body to this request.
|
Http.RequestBuilder |
bodyMultipart(java.util.List<Http.MultipartFormData.Part<akka.stream.javadsl.Source<akka.util.ByteString,?>>> data,
Files.TemporaryFileCreator temporaryFileCreator,
akka.stream.Materializer mat)
Set a Multipart Form url encoded body to this request.
|
Http.RequestBuilder |
bodyRaw(byte[] data)
Set a Binary Data to this request using a singleton temporary file creator.
|
Http.RequestBuilder |
bodyRaw(byte[] data,
Files.TemporaryFileCreator tempFileCreator)
Set a Binary Data to this request.
|
Http.RequestBuilder |
bodyRaw(akka.util.ByteString data)
Set a Binary Data to this request using a singleton temp file creator The
Content-Type header of the request is set to application/octet-stream.
|
Http.RequestBuilder |
bodyRaw(akka.util.ByteString data,
Files.TemporaryFileCreator tempFileCreator)
Set a Binary Data to this request.
|
Http.RequestBuilder |
bodyText(java.lang.String text)
Set a Text to this request.
|
Http.RequestBuilder |
bodyXml(org.w3c.dom.Document xml)
Set a XML to this request.
|
Http.RequestBuilder |
bodyXml(org.xml.sax.InputSource xml)
Set a XML to this request.
|
Http.RequestImpl |
build()
Builds the request.
|
java.util.Optional<java.util.List<java.security.cert.X509Certificate>> |
clientCertificateChain() |
Http.RequestBuilder |
clientCertificateChain(java.util.List<java.security.cert.X509Certificate> clientCertificateChain) |
Http.RequestBuilder |
cookie(Http.Cookie cookie)
Sets one cookie.
|
Http.Cookies |
cookies() |
java.util.Map<java.lang.String,java.lang.String> |
flash() |
Http.RequestBuilder |
flash(java.util.Map<java.lang.String,java.lang.String> data)
Sets cookies in a request.
|
Http.RequestBuilder |
flash(java.lang.String key,
java.lang.String value)
Sets a cookie in the request.
|
Http.Headers |
getHeaders() |
java.lang.String |
header(java.lang.String key)
Deprecated.
As of release 2.6, use
getHeaders() instead. |
Http.RequestBuilder |
header(java.lang.String key,
java.util.List<java.lang.String> values) |
Http.RequestBuilder |
header(java.lang.String key,
java.lang.String value) |
Http.RequestBuilder |
header(java.lang.String key,
java.lang.String[] values)
Deprecated.
As of release 2.6, use
header(String, List) instead. |
java.util.Map<java.lang.String,java.lang.String[]> |
headers()
Deprecated.
As of release 2.6, use
getHeaders() instead. |
Http.RequestBuilder |
headers(Http.Headers headers)
Set the headers to be used by the request builder.
|
Http.RequestBuilder |
headers(java.util.Map<java.lang.String,java.lang.String[]> headers)
Deprecated.
As of release 2.6, use
#headers(Headers) instead. |
java.lang.String[] |
headers(java.lang.String key)
Deprecated.
As of release 2.6, use
getHeaders() instead. |
java.lang.String |
host() |
Http.RequestBuilder |
host(java.lang.String host) |
java.lang.Long |
id() |
Http.RequestBuilder |
id(java.lang.Long id) |
java.lang.String |
method() |
Http.RequestBuilder |
method(java.lang.String method) |
java.lang.String |
path() |
Http.RequestBuilder |
path(java.lang.String path)
This method sets the path of the uri.
|
java.lang.String |
remoteAddress() |
Http.RequestBuilder |
remoteAddress(java.lang.String remoteAddress) |
boolean |
secure() |
Http.RequestBuilder |
secure(boolean secure) |
java.util.Map<java.lang.String,java.lang.String> |
session() |
Http.RequestBuilder |
session(java.util.Map<java.lang.String,java.lang.String> data)
Sets all parameters for the session.
|
Http.RequestBuilder |
session(java.lang.String key,
java.lang.String value)
Sets a session.
|
Http.RequestBuilder |
tag(java.lang.String key,
java.lang.String value)
Deprecated.
Use
attr(key, value) instead. |
java.util.Map<java.lang.String,java.lang.String> |
tags()
Deprecated.
Use typed attributes, i.e.
attrs() , instead. |
Http.RequestBuilder |
tags(java.util.Map<java.lang.String,java.lang.String> tags)
Deprecated.
Use
attrs(...) instead. |
java.lang.String |
uri() |
Http.RequestBuilder |
uri(java.lang.String str)
Sets the uri.
|
Http.RequestBuilder |
uri(java.net.URI uri) |
java.lang.String |
username()
Deprecated.
Use
attrs().get(Security.USERNAME) or
attrs().getOptional(Security.USERNAME) instead. |
Http.RequestBuilder |
username(java.lang.String username)
Deprecated.
Use
attr(Security.USERNAME, username) instead. |
java.lang.String |
version() |
Http.RequestBuilder |
version(java.lang.String version) |
protected play.api.mvc.Request<Http.RequestBody> req
public RequestBuilder()
public RequestBuilder(play.api.mvc.request.RequestFactory requestFactory)
requestFactory
- the incoming request factorypublic Http.RequestBody body()
@Deprecated public java.lang.String username()
attrs().get(Security.USERNAME)
or
attrs().getOptional(Security.USERNAME)
instead.attrs().getOptional(Security.USERNAME)
.@Deprecated public Http.RequestBuilder username(java.lang.String username)
attr(Security.USERNAME, username)
instead.attr(Security.USERNAME, username)
.username
- the username for the requestprotected Http.RequestBuilder body(Http.RequestBody body, java.lang.String contentType)
body
- the bodycontentType
- Content-Type header valueprotected Http.RequestBuilder body(Http.RequestBody body)
body
- The body.public Http.RequestBuilder bodyRaw(akka.util.ByteString data)
data
- the Binary Datapublic Http.RequestBuilder bodyRaw(akka.util.ByteString data, Files.TemporaryFileCreator tempFileCreator)
data
- the Binary DatatempFileCreator
- the temporary file creator for binary data.public Http.RequestBuilder bodyRaw(byte[] data)
data
- the Binary Datapublic Http.RequestBuilder bodyRaw(byte[] data, Files.TemporaryFileCreator tempFileCreator)
data
- the Binary DatatempFileCreator
- the temporary file creator for binary data.public Http.RequestBuilder bodyFormArrayValues(java.util.Map<java.lang.String,java.lang.String[]> data)
data
- the x-www-form-urlencoded parameterspublic Http.RequestBuilder bodyForm(java.util.Map<java.lang.String,java.lang.String> data)
data
- the x-www-form-urlencoded parameterspublic Http.RequestBuilder bodyMultipart(java.util.List<Http.MultipartFormData.Part<akka.stream.javadsl.Source<akka.util.ByteString,?>>> data, Files.TemporaryFileCreator temporaryFileCreator, akka.stream.Materializer mat)
data
- the multipart-form parameterstemporaryFileCreator
- the temporary file creator.mat
- a Akka Streams Materializerpublic Http.RequestBuilder bodyJson(com.fasterxml.jackson.databind.JsonNode node)
node
- the Json Nodepublic Http.RequestBuilder bodyJson(play.api.libs.json.JsValue json)
json
- the JsValuepublic Http.RequestBuilder bodyXml(org.xml.sax.InputSource xml)
xml
- the XMLpublic Http.RequestBuilder bodyXml(org.w3c.dom.Document xml)
The Content-Type header of the request is set to application/xml.
xml
- the XMLpublic Http.RequestBuilder bodyText(java.lang.String text)
text
- the textpublic Http.RequestImpl build()
public java.lang.Long id()
public Http.RequestBuilder id(java.lang.Long id)
id
- the id to be usedpublic <T> Http.RequestBuilder attr(TypedKey<T> key, T value)
T
- The type of the attribute to add.key
- The key of the attribute to add.value
- The value of the attribute to add.public Http.RequestBuilder attrs(TypedMap newAttrs)
newAttrs
- The attribute entries to add.public TypedMap attrs()
@Deprecated public java.util.Map<java.lang.String,java.lang.String> tags()
attrs()
, instead.@Deprecated public Http.RequestBuilder tags(java.util.Map<java.lang.String,java.lang.String> tags)
attrs(...)
instead.tags
- overwrites the tags for this request@Deprecated public Http.RequestBuilder tag(java.lang.String key, java.lang.String value)
attr(key, value)
instead.key
- the key for the tagvalue
- the value for the tagpublic java.lang.String method()
public Http.RequestBuilder method(java.lang.String method)
method
- sets the methodpublic java.lang.String uri()
public Http.RequestBuilder uri(java.net.URI uri)
public Http.RequestBuilder uri(java.lang.String str)
str
- the uripublic Http.RequestBuilder secure(boolean secure)
secure
- true if the request is securepublic boolean secure()
public java.lang.String host()
public Http.RequestBuilder host(java.lang.String host)
host
- sets the host in the headerpublic java.lang.String path()
public Http.RequestBuilder path(java.lang.String path)
path
- the path after the port and for the query in a uripublic java.lang.String version()
public Http.RequestBuilder version(java.lang.String version)
version
- the version@Deprecated public java.lang.String header(java.lang.String key)
getHeaders()
instead.key
- the key to be used in the header@Deprecated public java.lang.String[] headers(java.lang.String key)
getHeaders()
instead.key
- the key to be used in the header@Deprecated public java.util.Map<java.lang.String,java.lang.String[]> headers()
getHeaders()
instead.public Http.Headers getHeaders()
@Deprecated public Http.RequestBuilder headers(java.util.Map<java.lang.String,java.lang.String[]> headers)
#headers(Headers)
instead.headers
- the headers to be replacedpublic Http.RequestBuilder headers(Http.Headers headers)
headers
- the headers to be replaced@Deprecated public Http.RequestBuilder header(java.lang.String key, java.lang.String[] values)
header(String, List)
instead.key
- the key for in the headervalues
- the values associated with the keypublic Http.RequestBuilder header(java.lang.String key, java.util.List<java.lang.String> values)
key
- the key for in the headervalues
- the values associated with the keypublic Http.RequestBuilder header(java.lang.String key, java.lang.String value)
key
- the key for in the headervalue
- the value (one) associated with the keypublic Http.Cookies cookies()
public Http.RequestBuilder cookie(Http.Cookie cookie)
cookie
- the cookie to be setpublic java.util.Map<java.lang.String,java.lang.String> flash()
public Http.RequestBuilder flash(java.lang.String key, java.lang.String value)
key
- the key for the cookievalue
- the value for the cookiepublic Http.RequestBuilder flash(java.util.Map<java.lang.String,java.lang.String> data)
data
- a key value mapping of cookiespublic java.util.Map<java.lang.String,java.lang.String> session()
public Http.RequestBuilder session(java.lang.String key, java.lang.String value)
key
- the key for the sessionvalue
- the value associated with the key for the sessionpublic Http.RequestBuilder session(java.util.Map<java.lang.String,java.lang.String> data)
data
- a key value mapping of the session datapublic java.lang.String remoteAddress()
public Http.RequestBuilder remoteAddress(java.lang.String remoteAddress)
remoteAddress
- sets the remote addresspublic java.util.Optional<java.util.List<java.security.cert.X509Certificate>> clientCertificateChain()
public Http.RequestBuilder clientCertificateChain(java.util.List<java.security.cert.X509Certificate> clientCertificateChain)
clientCertificateChain
- sets the X509Certificates to use