public class Result
extends java.lang.Object
Constructor and Description |
---|
Result(int status)
Create a result with no entity.
|
Result(int status,
HttpEntity body)
Create a result.
|
Result(int status,
java.util.Map<java.lang.String,java.lang.String> headers)
Create a result with no body.
|
Result(int status,
java.util.Map<java.lang.String,java.lang.String> headers,
HttpEntity body)
Create a result.
|
Result(int status,
java.lang.String reasonPhrase,
java.util.Map<java.lang.String,java.lang.String> headers,
HttpEntity body)
Create a result.
|
Result(ResponseHeader header,
HttpEntity body)
Create a result from a Scala ResponseHeader and a body.
|
Result(ResponseHeader header,
HttpEntity body,
Http.Session session,
Http.Flash flash,
java.util.List<Http.Cookie> cookies)
Create a result from a Scala ResponseHeader and a body.
|
Modifier and Type | Method and Description |
---|---|
Result |
as(java.lang.String contentType)
Return a copy of the result with a different Content-Type header.
|
play.api.mvc.Result |
asScala()
Convert this result to a Scala result.
|
HttpEntity |
body()
Get the body of this result.
|
java.util.Optional<java.lang.String> |
charset()
Extracts the Charset of this Result value.
|
java.util.Optional<java.lang.String> |
contentType()
Extracts the Content-Type of this Result value.
|
Http.Cookie |
cookie(java.lang.String name)
Extracts a Cookie value from this Result value
|
Http.Cookies |
cookies()
Extracts the Cookies (an iterator) from this result value.
|
Result |
discardCookie(java.lang.String name)
Discard a cookie on the default path ("/") with no domain and that's not secure.
|
Result |
discardCookie(java.lang.String name,
java.lang.String path)
Discard a cookie on the given path with no domain and not that's secure.
|
Result |
discardCookie(java.lang.String name,
java.lang.String path,
java.lang.String domain)
Discard a cookie on the given path and domain that's not secure.
|
Result |
discardCookie(java.lang.String name,
java.lang.String path,
java.lang.String domain,
boolean secure)
Discard a cookie in this result
|
Http.Flash |
flash()
Extracts the Flash values of this Result value.
|
protected ResponseHeader |
getHeader()
Get the response header
|
java.util.Optional<java.lang.String> |
header(java.lang.String header)
Extracts an Header value of this Result value.
|
java.util.Map<java.lang.String,java.lang.String> |
headers()
Extracts all Headers of this Result value.
|
java.util.Optional<java.lang.String> |
reasonPhrase()
Get the reason phrase, if it was set.
|
java.util.Optional<java.lang.String> |
redirectLocation()
Extracts the Location header of this Result value if this Result is a Redirect.
|
Http.Session |
session()
Extracts the Session of this Result value.
|
int |
status()
Get the status.
|
Result |
withCookies(Http.Cookie... newCookies)
Returns a copy of this result with the given cookies.
|
Result |
withHeader(java.lang.String name,
java.lang.String value)
Return a copy of this result with the given header.
|
Result |
withHeaders(java.lang.String... nameValues)
Return a copy of this result with the given headers.
|
public Result(ResponseHeader header, HttpEntity body, Http.Session session, Http.Flash flash, java.util.List<Http.Cookie> cookies)
header
- the response headerbody
- the response body.session
- the session set on the response.flash
- the flash object on the response.cookies
- the cookies set on the response.public Result(ResponseHeader header, HttpEntity body)
header
- the response headerbody
- the response body.public Result(int status, java.lang.String reasonPhrase, java.util.Map<java.lang.String,java.lang.String> headers, HttpEntity body)
status
- The status.reasonPhrase
- The reason phrase, if a non default reason phrase is required.headers
- The headers.body
- The body.public Result(int status, java.util.Map<java.lang.String,java.lang.String> headers, HttpEntity body)
status
- The status.headers
- The headers.body
- The body.public Result(int status, java.util.Map<java.lang.String,java.lang.String> headers)
status
- The status.headers
- The headers.public Result(int status, HttpEntity body)
status
- The status.body
- The entity.public Result(int status)
status
- The status.public int status()
public java.util.Optional<java.lang.String> reasonPhrase()
protected ResponseHeader getHeader()
public HttpEntity body()
public java.util.Optional<java.lang.String> redirectLocation()
public java.util.Optional<java.lang.String> header(java.lang.String header)
header
- the header name.public java.util.Map<java.lang.String,java.lang.String> headers()
public java.util.Optional<java.lang.String> contentType()
public java.util.Optional<java.lang.String> charset()
public Http.Flash flash()
public Http.Session session()
public Http.Cookie cookie(java.lang.String name)
name
- the cookie's name.public Http.Cookies cookies()
public Result withCookies(Http.Cookie... newCookies)
newCookies
- the cookies to add to the result.public Result discardCookie(java.lang.String name)
name
- The name of the cookie to discard, must not be nullpublic Result discardCookie(java.lang.String name, java.lang.String path)
name
- The name of the cookie to discard, must not be nullpath
- The path of the cookie to discard, may be nullpublic Result discardCookie(java.lang.String name, java.lang.String path, java.lang.String domain)
name
- The name of the cookie to discard, must not be nullpath
- The path of the cookie te discard, may be nulldomain
- The domain of the cookie to discard, may be nullpublic Result discardCookie(java.lang.String name, java.lang.String path, java.lang.String domain, boolean secure)
name
- The name of the cookie to discard, must not be nullpath
- The path of the cookie te discard, may be nulldomain
- The domain of the cookie to discard, may be nullsecure
- Whether the cookie to discard is securepublic Result withHeader(java.lang.String name, java.lang.String value)
name
- the header namevalue
- the header valuepublic Result withHeaders(java.lang.String... nameValues)
nameValues
- the array of names and values.public Result as(java.lang.String contentType)
contentType
- the content type to setpublic play.api.mvc.Result asScala()