public static class Http.Response
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
boolean |
chunked |
java.lang.String |
contentType
Response content type
|
java.util.Map<java.lang.String,Http.Cookie> |
cookies
Response cookies
|
static java.lang.ThreadLocal<Http.Response> |
current
Bind to thread
|
java.lang.Object |
direct
Send this file directly
|
java.lang.String |
encoding
The encoding used when writing response to client
|
java.util.Map<java.lang.String,Http.Header> |
headers
Response headers
|
java.io.ByteArrayOutputStream |
out
Response body stream
|
java.lang.Integer |
status
Response status code
|
Constructor and Description |
---|
Response() |
Modifier and Type | Method and Description |
---|---|
void |
accessControl(java.lang.String allowOrigin)
Add headers to allow cross-domain requests.
|
void |
accessControl(java.lang.String allowOrigin,
boolean allowCredentials)
Add headers to allow cross-domain requests.
|
void |
accessControl(java.lang.String allowOrigin,
java.lang.String allowMethods,
boolean allowCredentials)
Add headers to allow cross-domain requests.
|
void |
cacheFor(java.lang.String duration)
Add a cache-control header
|
void |
cacheFor(java.lang.String etag,
java.lang.String duration,
long lastModified)
Add cache-control headers
|
static Http.Response |
current()
Retrieve the current response
|
java.lang.String |
getHeader(java.lang.String name)
Get a response header
|
void |
onWriteChunk(F.Action<java.lang.Object> handler) |
void |
print(java.lang.Object o) |
void |
removeCookie(java.lang.String name)
Removes the specified cookie with path /
|
void |
removeCookie(java.lang.String name,
java.lang.String path)
Removes the cookie
|
void |
reset() |
void |
setContentTypeIfNotSet(java.lang.String contentType) |
void |
setCookie(java.lang.String name,
java.lang.String value)
Set a new cookie
|
void |
setCookie(java.lang.String name,
java.lang.String value,
java.lang.String duration)
Set a new cookie that will expire in (current) + duration
|
void |
setCookie(java.lang.String name,
java.lang.String value,
java.lang.String domain,
java.lang.String path,
java.lang.Integer maxAge,
boolean secure) |
void |
setCookie(java.lang.String name,
java.lang.String value,
java.lang.String domain,
java.lang.String path,
java.lang.Integer maxAge,
boolean secure,
boolean httpOnly) |
void |
setHeader(java.lang.String name,
java.lang.String value)
Set a response header
|
void |
writeChunk(java.lang.Object o) |
public java.lang.Integer status
public java.lang.String contentType
public java.util.Map<java.lang.String,Http.Header> headers
public java.util.Map<java.lang.String,Http.Cookie> cookies
public java.io.ByteArrayOutputStream out
public java.lang.Object direct
public java.lang.String encoding
public static final java.lang.ThreadLocal<Http.Response> current
public boolean chunked
public static Http.Response current()
public java.lang.String getHeader(java.lang.String name)
name
- Header name case-insensitivepublic void setHeader(java.lang.String name, java.lang.String value)
name
- Header namevalue
- Header valuepublic void setContentTypeIfNotSet(java.lang.String contentType)
public void setCookie(java.lang.String name, java.lang.String value)
name
- Cookie namevalue
- Cookie valuepublic void removeCookie(java.lang.String name)
name
- cookie namepublic void removeCookie(java.lang.String name, java.lang.String path)
name
- cookie namepath
- cookie pathpublic void setCookie(java.lang.String name, java.lang.String value, java.lang.String duration)
name
- the cookie namevalue
- The cookie valueduration
- the cookie duration (Ex: 3d)public void setCookie(java.lang.String name, java.lang.String value, java.lang.String domain, java.lang.String path, java.lang.Integer maxAge, boolean secure)
public void setCookie(java.lang.String name, java.lang.String value, java.lang.String domain, java.lang.String path, java.lang.Integer maxAge, boolean secure, boolean httpOnly)
public void cacheFor(java.lang.String duration)
duration
- Ex: 3hpublic void cacheFor(java.lang.String etag, java.lang.String duration, long lastModified)
etag
- the Etag valueduration
- the cache duration (Ex: 3h)lastModified
- The last modified datepublic void accessControl(java.lang.String allowOrigin)
allowOrigin
- a comma separated list of domains allowed to perform the x-domain call, or "*" for all.public void accessControl(java.lang.String allowOrigin, boolean allowCredentials)
allowOrigin
- a comma separated list of domains allowed to perform the x-domain call, or "*" for all.allowCredentials
- Let the browser send the cookies when doing a x-domain request. Only respected by the browser if
allowOrigin != "*"public void accessControl(java.lang.String allowOrigin, java.lang.String allowMethods, boolean allowCredentials)
allowOrigin
- a comma separated list of domains allowed to perform the x-domain call, or "*" for all.allowMethods
- a comma separated list of HTTP methods allowed, or null for all.allowCredentials
- Let the browser send the cookies when doing a x-domain request. Only respected by the browser if
allowOrigin != "*"public void print(java.lang.Object o)
public void reset()
public void writeChunk(java.lang.Object o)
public void onWriteChunk(F.Action<java.lang.Object> handler)
Guillaume Bort & zenexity - Distributed under Apache 2 licence, without any warrantly