public static class Http.Response extends java.lang.Object implements Http.HeaderNames
ACCEPT, ACCEPT_CHARSET, ACCEPT_ENCODING, ACCEPT_LANGUAGE, ACCEPT_RANGES, ACCESS_CONTROL_ALLOW_CREDENTIALS, ACCESS_CONTROL_ALLOW_HEADERS, ACCESS_CONTROL_ALLOW_METHODS, ACCESS_CONTROL_ALLOW_ORIGIN, ACCESS_CONTROL_EXPOSE_HEADERS, ACCESS_CONTROL_MAX_AGE, ACCESS_CONTROL_REQUEST_HEADERS, ACCESS_CONTROL_REQUEST_METHOD, AGE, ALLOW, AUTHORIZATION, CACHE_CONTROL, CONNECTION, CONTENT_DISPOSITION, CONTENT_ENCODING, CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_LOCATION, CONTENT_MD5, CONTENT_RANGE, CONTENT_TRANSFER_ENCODING, CONTENT_TYPE, COOKIE, DATE, ETAG, EXPECT, EXPIRES, FORWARDED, FROM, HOST, IF_MATCH, IF_MODIFIED_SINCE, IF_NONE_MATCH, IF_RANGE, IF_UNMODIFIED_SINCE, LAST_MODIFIED, LOCATION, MAX_FORWARDS, ORIGIN, PRAGMA, PROXY_AUTHENTICATE, PROXY_AUTHORIZATION, RANGE, REFERER, RETRY_AFTER, SERVER, SET_COOKIE, SET_COOKIE2, TE, TRAILER, TRANSFER_ENCODING, UPGRADE, USER_AGENT, VARY, VIA, WARNING, WWW_AUTHENTICATE, X_FORWARDED_FOR, X_FORWARDED_HOST, X_FORWARDED_PORT, X_FORWARDED_PROTO, X_REQUESTED_WITH
Constructor and Description |
---|
Response() |
Modifier and Type | Method and Description |
---|---|
java.util.Optional<Http.Cookie> |
cookie(java.lang.String name) |
java.util.Collection<Http.Cookie> |
cookies() |
void |
discardCookie(java.lang.String name)
Discard a cookie on the default path ("/") with no domain and that's not secure.
|
void |
discardCookie(java.lang.String name,
java.lang.String path)
Discard a cookie on the given path with no domain and not that's secure.
|
void |
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.
|
void |
discardCookie(java.lang.String name,
java.lang.String path,
java.lang.String domain,
boolean secure)
Discard a cookie in this result
|
java.util.Map<java.lang.String,java.lang.String> |
getHeaders()
Gets the current response headers.
|
void |
setContentType(java.lang.String contentType)
Deprecated.
noop. Use
Result.as(String) instead. |
void |
setCookie(Http.Cookie cookie)
Set a new cookie.
|
void |
setCookie(java.lang.String name,
java.lang.String value)
Deprecated.
Use
setCookie(Http.Cookie) instead. |
void |
setCookie(java.lang.String name,
java.lang.String value,
java.lang.Integer maxAge)
Deprecated.
Use
setCookie(Http.Cookie) instead. |
void |
setCookie(java.lang.String name,
java.lang.String value,
java.lang.Integer maxAge,
java.lang.String path)
Deprecated.
Use
setCookie(Http.Cookie) instead. |
void |
setCookie(java.lang.String name,
java.lang.String value,
java.lang.Integer maxAge,
java.lang.String path,
java.lang.String domain)
Deprecated.
Use
setCookie(Http.Cookie) instead. |
void |
setCookie(java.lang.String name,
java.lang.String value,
java.lang.Integer maxAge,
java.lang.String path,
java.lang.String domain,
boolean secure,
boolean httpOnly)
Deprecated.
Use
setCookie(Http.Cookie) instead. |
void |
setHeader(java.lang.String name,
java.lang.String value)
Adds a new header to the response.
|
public void setHeader(java.lang.String name, java.lang.String value)
name
- The name of the header, must not be nullvalue
- The value of the header, must not be nullpublic java.util.Map<java.lang.String,java.lang.String> getHeaders()
@Deprecated public void setContentType(java.lang.String contentType)
Result.as(String)
instead.contentType
- Deprecated@Deprecated public void setCookie(java.lang.String name, java.lang.String value)
setCookie(Http.Cookie)
instead.response().setCookie("theme", "blue");
name
- Cookie name, must not be nullvalue
- Cookie value@Deprecated public void setCookie(java.lang.String name, java.lang.String value, java.lang.Integer maxAge)
setCookie(Http.Cookie)
instead.name
- Cookie name, must not be nullvalue
- Cookie valuemaxAge
- Cookie duration (null for a transient cookie and 0 or less for a cookie that expires now)@Deprecated public void setCookie(java.lang.String name, java.lang.String value, java.lang.Integer maxAge, java.lang.String path)
setCookie(Http.Cookie)
instead.name
- Cookie name, must not be nullvalue
- Cookie valuemaxAge
- Cookie duration (null for a transient cookie and 0 or less for a cookie that expires now)path
- Cookie path@Deprecated public void setCookie(java.lang.String name, java.lang.String value, java.lang.Integer maxAge, java.lang.String path, java.lang.String domain)
setCookie(Http.Cookie)
instead.name
- Cookie name, must not be nullvalue
- Cookie valuemaxAge
- Cookie duration (null for a transient cookie and 0 or less for a cookie that expires now)path
- Cookie pathdomain
- Cookie domainpublic void setCookie(java.lang.String name, java.lang.String value, java.lang.Integer maxAge, java.lang.String path, java.lang.String domain, boolean secure, boolean httpOnly)
setCookie(Http.Cookie)
instead.name
- Cookie name, must not be nullvalue
- Cookie valuemaxAge
- Cookie duration (null for a transient cookie and 0 or less for a cookie that expires now)path
- Cookie pathdomain
- Cookie domainsecure
- Whether the cookie is secured (for HTTPS requests)httpOnly
- Whether the cookie is HTTP only (i.e. not accessible from client-side JavaScript code)public void setCookie(Http.Cookie cookie)
cookie
- to setpublic void discardCookie(java.lang.String name)
name
- The name of the cookie to discard, must not be nullpublic void 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 te discard, may be nullpublic void 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 void 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 java.util.Collection<Http.Cookie> cookies()
public java.util.Optional<Http.Cookie> cookie(java.lang.String name)