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