public class Response extends Object
Page.| Constructor and Description |
|---|
Response(OutputStream content)
Creates a new response.
|
| Modifier and Type | Method and Description |
|---|---|
Response |
addHeader(String name,
String value)
Adds a header field with the given name and value to this response.
|
protected static Map<String,String> |
createHeader(String name,
String value)
Creates a header map containing a single header.
|
OutputStream |
getContent()
Returns the output stream the response body has to be written to.
|
String |
getContentType()
Returns the content type of the response.
|
Iterable<Header> |
getHeaders()
Returns HTTP headers of the response.
|
int |
getStatusCode()
Returns the HTTP status code of the response.
|
String |
getStatusText()
Returns the HTTP status text.
|
Response |
setContentType(String contentType)
Sets the content type of this response.
|
Response |
setStatusCode(int statusCode)
Sets the status code of this response.
|
Response |
setStatusText(String statusText)
Sets the text of the HTTP status line.
|
Response |
write(byte[] data)
Writes the given data to this response’s
content
output stream. |
Response |
write(String text)
Writes the text to this response’s
content output
stream. |
public Response(OutputStream content)
content - The output stream the response body will be written topublic int getStatusCode()
public Response setStatusCode(int statusCode)
statusCode - The status code of this responsepublic String getStatusText()
public Response setStatusText(String statusText)
statusText - The text of the HTTP status linepublic String getContentType()
public Response setContentType(String contentType)
contentType - The content type of this responsepublic Response write(String text) throws IOException
content output
stream.text - The text to writeIOException - if an I/O error occurspublic Response write(byte[] data) throws IOException
content
output stream.data - The data to writeIOException - if an I/O error occurspublic Iterable<Header> getHeaders()
null if no headers
are returned.public Response addHeader(String name, String value)
name - The name of the header fieldvalue - The value of the header fieldpublic OutputStream getContent()
Copyright © 2026. All rights reserved.