public final class Response extends Object
| Constructor and Description |
|---|
Response() |
| Modifier and Type | Method and Description |
|---|---|
Response |
andBinaryContent(byte[] content)
Sends binary content to the client skipping rendering
|
Response |
andBinaryFile(File file)
Sends a binary file to the client skipping rendering
|
Response |
andBody(String body)
Sets the body of the response.
|
Response |
andCharset(String charset)
Sets a specific charset to the response
|
Response |
andContent(Map<String,Object> content)
Adds an additional content map to the content rendered in the template.
|
Response |
andContent(String name,
Object object)
Adds a value to the template that can be accessed using ${name} in the template
|
Response |
andContentType(String contentType)
Sets a specific content type to use for the response.
|
Response |
andCookie(io.undertow.server.handlers.Cookie cookie)
Adds an additional Cookie to the response which is passed to the client
|
Response |
andEmptyBody()
Disables template rendering, sending an empty body in the response
|
Response |
andEtag()
Adds an ETag header to the response by hashing (MD5) the response body.
|
Response |
andHeader(io.undertow.util.HttpString key,
String value)
Adds an additional header to the request response.
|
Response |
andHeaders(Map<io.undertow.util.HttpString,String> headers)
Adds an additional header map to the response.
|
Response |
andJsonBody(Object jsonObject)
Converts a given Object to JSON and passing it to the response.
|
Response |
andTemplate(String template)
Sets a specific template to use for the response
|
Response |
andTextBody(String text)
Sets the body of the response.
|
Response |
end()
Tells a filter that the response ends and that the request handler
should not execute further filters by sending the current response
to the client.
|
byte[] |
getBinaryContent() |
String |
getBinaryFileName() |
String |
getBody() |
String |
getCharset() |
Map<String,Object> |
getContent() |
String |
getContentType() |
List<io.undertow.server.handlers.Cookie> |
getCookies() |
Map<io.undertow.util.HttpString,String> |
getHeaders() |
String |
getRedirectTo() |
int |
getStatusCode() |
String |
getTemplate() |
boolean |
isBinary() |
boolean |
isEndResponse() |
boolean |
isETag() |
boolean |
isRedirect() |
boolean |
isRendered() |
static Response |
withBadRequest()
Creates a response object with HTTP status code 400
|
static Response |
withCreated()
Creates a response object with HTTP status code 201
|
static Response |
withForbidden()
Creates a response object with HTTP status code 401
|
static Response |
withInternalServerError()
Creates a response object with HTTP status code 500
|
static Response |
withNotFound()
Creates a response object with HTTP status code 404
|
static Response |
withOk()
Creates a response object with HTTP status code 200
|
static Response |
withRedirect(String redirectTo)
Creates a response object with a given url to redirect to
|
static Response |
withStatusCode(int statusCode)
Creates a response object with a given HTTP status code
|
static Response |
withUnauthorized()
Creates a response object with HTTP status code 403
|
public int getStatusCode()
public String getContentType()
public String getCharset()
public String getBody()
public List<io.undertow.server.handlers.Cookie> getCookies()
public byte[] getBinaryContent()
public String getTemplate()
public boolean isETag()
public String getBinaryFileName()
public boolean isRedirect()
public boolean isBinary()
public boolean isRendered()
public boolean isEndResponse()
public String getRedirectTo()
public static Response withOk()
Responsepublic static Response withCreated()
Responsepublic static Response withNotFound()
Responsepublic static Response withForbidden()
Responsepublic static Response withUnauthorized()
Responsepublic static Response withBadRequest()
Responsepublic static Response withInternalServerError()
Responsepublic static Response withStatusCode(int statusCode)
statusCode - The status code to setResponsepublic static Response withRedirect(String redirectTo)
redirectTo - The URL to redirect toResponsepublic Response andTemplate(String template)
template - The path to the template (e.g. /mytemplate/template.ftl)Responsepublic Response andContentType(String contentType)
contentType - The content type to useResponsepublic Response andCharset(String charset)
charset - The charset to useResponsepublic Response andContent(String name, Object object)
name - The name of the valueobject - The actual valueResponsepublic Response andBody(String body)
body - The body for the responseResponsepublic Response andCookie(io.undertow.server.handlers.Cookie cookie)
cookie - The cookie to addResponsepublic Response andJsonBody(Object jsonObject)
jsonObject - The object to convert to JSONResponsepublic Response andBinaryFile(File file)
file - The file to sendResponsepublic Response andBinaryContent(byte[] content)
content - The content to to sendResponsepublic Response andTextBody(String text)
text - The text for the responseResponsepublic Response andEmptyBody()
Responsepublic Response andHeader(io.undertow.util.HttpString key, String value)
key - The header constant from Headers class (e.g. Headers.CONTENT_TYPE)value - The header valueResponsepublic Response andContent(Map<String,Object> content)
content - The content map to addResponsepublic Response andHeaders(Map<io.undertow.util.HttpString,String> headers)
headers - The headers map to addResponsepublic Response andEtag()
ResponseCopyright © 2016. All rights reserved.