WebApplicationResponse
, Closeable
, Flushable
, AutoCloseable
, HttpServletResponse
, ServletResponse
DefaultWebApplicationServerResponse
, EmbeddedResponse
, NanoResponse
public class DefaultWebApplicationResponse extends ServletOutputStream implements WebApplicationResponse
Modifier and Type | Field | Description |
---|---|---|
protected boolean |
bodyOnly |
Stores the body only flag.
|
protected byte[] |
buffer |
Stores the buffer.
|
protected String |
characterEncoding |
Stores the character encoding.
|
protected boolean |
characterEncodingSet |
Stores if the character encoding has been set manually.
|
protected boolean |
committed |
Stores the committed flag.
|
protected long |
contentLength |
Stores the content length.
|
protected String |
contentType |
Stores the content type.
|
protected boolean |
contentTypeSet |
Stores if the content type has been set manually.
|
protected List<Cookie> |
cookies |
Stores the cookies.
|
protected boolean |
gotOutput |
Stores if we acquired the output stream.
|
protected boolean |
gotWriter |
Stores if we acquired the writer.
|
protected DefaultHttpHeaderManager |
headerManager |
Stores the header manager.
|
protected int |
index |
Stores the index.
|
protected Locale |
locale |
Stores the locale.
|
protected OutputStream |
outputStream |
Stores the output stream.
|
protected int |
status |
Stores the status code.
|
protected String |
statusMessage |
Stores the status message.
|
protected WebApplication |
webApplication |
Stores the web application.
|
protected PrintWriter |
writer |
Stores the writer.
|
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_FOUND, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_ENTITY_TOO_LARGE, SC_REQUEST_TIMEOUT, SC_REQUEST_URI_TOO_LONG, SC_REQUESTED_RANGE_NOT_SATISFIABLE, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY
Constructor | Description |
---|---|
DefaultWebApplicationResponse() |
Constructor.
|
Modifier and Type | Method | Description |
---|---|---|
void |
addCookie(Cookie cookie) |
Add the cookie.
|
void |
addDateHeader(String name,
long date) |
Add the date header.
|
void |
addHeader(String name,
String value) |
Add the header.
|
void |
addIntHeader(String name,
int value) |
Add the integer header.
|
void |
close() |
Close the output stream.
|
boolean |
containsHeader(String name) |
Contains the given header.
|
String |
encodeRedirectUrl(String url) |
Deprecated.
|
String |
encodeRedirectURL(String url) |
Encode the redirect URL.
|
String |
encodeUrl(String url) |
Deprecated.
|
String |
encodeURL(String url) |
Encode the URL.
|
void |
flush() |
Flush the output stream.
|
void |
flushBuffer() |
Flush the buffer.
|
int |
getBufferSize() |
Get the buffer size.
|
String |
getCharacterEncoding() |
Get the character encoding.
|
long |
getContentLength() |
Get the content length.
|
String |
getContentType() |
Get the content type.
|
Collection<Cookie> |
getCookies() |
Get the cookies.
|
String |
getHeader(String name) |
Get the header.
|
Collection<String> |
getHeaderNames() |
Get the header names.
|
Collection<String> |
getHeaders(String name) |
Get the headers.
|
Locale |
getLocale() |
Get the locale.
|
ServletOutputStream |
getOutputStream() |
Get the output stream.
|
int |
getStatus() |
Get the status.
|
String |
getStatusMessage() |
Get the status message.
|
OutputStream |
getUnderlyingOutputStream() |
Get the underlying output stream.
|
WebApplication |
getWebApplication() |
Get the web application.
|
PrintWriter |
getWriter() |
Get the writer.
|
boolean |
isBodyOnly() |
Is body only.
|
boolean |
isCommitted() |
Is committed.
|
boolean |
isReady() |
Is the output stream ready?
|
void |
reset() |
Reset the response.
|
void |
resetBuffer() |
Reset the buffer.
|
void |
sendError(int status) |
Send an error.
|
void |
sendError(int status,
String statusMessage) |
Send the error.
|
void |
sendRedirect(String location) |
Send the redirect.
|
void |
setBodyOnly(boolean bodyOnly) |
Set the body only flag.
|
void |
setBufferSize(int bufferSize) |
Set the buffer size.
|
void |
setCharacterEncoding(String characterEncoding) |
Set the character encoding.
|
void |
setCommitted(boolean committed) |
Set the committed.
|
void |
setContentLength(int contentLength) |
Set the content length.
|
void |
setContentLengthLong(long contentLength) |
Set the content length.
|
void |
setContentType(String type) |
Set the content type.
|
void |
setDateHeader(String name,
long date) |
Set the date header.
|
void |
setHeader(String name,
String value) |
Set the header.
|
void |
setIntHeader(String name,
int value) |
Set the int header.
|
void |
setLocale(Locale locale) |
Set the locale.
|
void |
setOutputStream(ServletOutputStream outputStream) |
Set the output stream.
|
void |
setStatus(int status) |
Set the status.
|
void |
setStatus(int status,
String statusMessage) |
Deprecated.
|
void |
setUnderlyingOutputStream(OutputStream outputStream) |
Set the underlying output stream.
|
void |
setWebApplication(WebApplication webApplication) |
Set the web application.
|
void |
setWriteListener(WriteListener listener) |
Set the write listener.
|
protected void |
verifyNotCommitted(String methodName) |
Verify we are not committed.
|
void |
write(int integer) |
Write the integer.
|
getTrailerFields, setTrailerFields
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
write, write
protected boolean bodyOnly
protected byte[] buffer
protected String characterEncoding
protected boolean characterEncodingSet
protected boolean committed
protected long contentLength
protected String contentType
protected boolean contentTypeSet
protected boolean gotOutput
protected boolean gotWriter
protected DefaultHttpHeaderManager headerManager
protected int index
protected Locale locale
protected PrintWriter writer
protected OutputStream outputStream
protected int status
protected String statusMessage
protected WebApplication webApplication
public DefaultWebApplicationResponse()
public void addCookie(Cookie cookie)
addCookie
in interface HttpServletResponse
cookie
- the cookie.public void addDateHeader(String name, long date)
addDateHeader
in interface HttpServletResponse
name
- the header name.date
- the header date value.public void addHeader(String name, String value)
addHeader
in interface HttpServletResponse
name
- the name.value
- the value.public void addIntHeader(String name, int value)
addIntHeader
in interface HttpServletResponse
name
- the name of the header.value
- the value of the header.public boolean containsHeader(String name)
containsHeader
in interface HttpServletResponse
name
- the header name.public String encodeRedirectURL(String url)
encodeRedirectURL
in interface HttpServletResponse
url
- the url.public String encodeRedirectUrl(String url)
encodeRedirectUrl
in interface HttpServletResponse
url
- the url.public String encodeURL(String url)
encodeURL
in interface HttpServletResponse
url
- the URL.public String encodeUrl(String url)
encodeUrl
in interface HttpServletResponse
url
- the url.public void flushBuffer() throws IOException
flushBuffer
in interface ServletResponse
IOException
- when an I/O error occurs.public String getCharacterEncoding()
getCharacterEncoding
in interface ServletResponse
public int getBufferSize()
getBufferSize
in interface ServletResponse
public long getContentLength()
public String getContentType()
getContentType
in interface ServletResponse
public String getHeader(String name)
getHeader
in interface HttpServletResponse
name
- the header name.public Collection<String> getHeaderNames()
getHeaderNames
in interface HttpServletResponse
public Collection<String> getHeaders(String name)
getHeaders
in interface HttpServletResponse
name
- the name of the header.public Locale getLocale()
getLocale
in interface ServletResponse
public ServletOutputStream getOutputStream() throws IOException
getOutputStream
in interface ServletResponse
IOException
- when an I/O error occurs.public int getStatus()
getStatus
in interface HttpServletResponse
public String getStatusMessage()
public WebApplication getWebApplication()
public PrintWriter getWriter() throws IOException
getWriter
in interface ServletResponse
IOException
- when an I/O error occurs.public boolean isBodyOnly()
public boolean isCommitted()
isCommitted
in interface ServletResponse
public void reset()
reset
in interface ServletResponse
public void resetBuffer()
resetBuffer
in interface ServletResponse
public void sendError(int status) throws IOException
sendError
in interface HttpServletResponse
status
- the error code.IOException
- when an I/O error occurs.public void sendError(int status, String statusMessage) throws IOException
sendError
in interface HttpServletResponse
status
- the status code.statusMessage
- the message.IOException
- when an I/O error occurs.public void sendRedirect(String location) throws IOException
sendRedirect
in interface HttpServletResponse
location
- the location.IOException
- when an I/O error occurs.public void setBodyOnly(boolean bodyOnly)
bodyOnly
- flag.public void setBufferSize(int bufferSize)
setBufferSize
in interface ServletResponse
bufferSize
- the buffer size.public void setCharacterEncoding(String characterEncoding)
setCharacterEncoding
in interface ServletResponse
characterEncoding
- the character encoding.public void setCommitted(boolean committed)
committed
- the committed flag.public void setContentLength(int contentLength)
setContentLength
in interface ServletResponse
contentLength
- the content length.public void setContentLengthLong(long contentLength)
setContentLengthLong
in interface ServletResponse
contentLength
- the content length.public void setContentType(String type)
setContentType
in interface ServletResponse
type
- the content type.public void setDateHeader(String name, long date)
setDateHeader
in interface HttpServletResponse
name
- the header name.date
- the date.public void setHeader(String name, String value)
setHeader
in interface HttpServletResponse
name
- the name.value
- the value.public void setIntHeader(String name, int value)
setIntHeader
in interface HttpServletResponse
name
- the header name.value
- the header value.public void setLocale(Locale locale)
setLocale
in interface ServletResponse
locale
- the locale.public void setOutputStream(ServletOutputStream outputStream)
outputStream
- the output stream.public void setStatus(int status)
setStatus
in interface HttpServletResponse
status
- the status code.public void setStatus(int status, String statusMessage)
setStatus
in interface HttpServletResponse
status
- the status.statusMessage
- the messagepublic void setWebApplication(WebApplication webApplication)
webApplication
- the web application.protected void verifyNotCommitted(String methodName)
methodName
- the method we are checking for.public Collection<Cookie> getCookies()
getCookies
in interface WebApplicationResponse
public OutputStream getUnderlyingOutputStream()
getUnderlyingOutputStream
in interface WebApplicationResponse
public void setUnderlyingOutputStream(OutputStream outputStream)
setUnderlyingOutputStream
in interface WebApplicationResponse
outputStream
- the underlying output stream.public void close() throws IOException
close
in interface AutoCloseable
close
in interface Closeable
close
in class OutputStream
IOException
- when an I/O error occurs.public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
- when an I/O error occurs.public boolean isReady()
isReady
in class ServletOutputStream
public void setWriteListener(WriteListener listener)
setWriteListener
in class ServletOutputStream
listener
- the write listener.public void write(int integer) throws IOException
write
in class OutputStream
integer
- the integer.IOException
- when an I/O error occurs.Copyright © 2020 Piranha Cloud. All rights reserved.