Module cloud.piranha.webapp.impl
Package cloud.piranha.webapp.impl
Class DefaultWebApplicationResponse
java.lang.Object
java.io.OutputStream
jakarta.servlet.ServletOutputStream
cloud.piranha.webapp.impl.DefaultWebApplicationResponse
- All Implemented Interfaces:
WebApplicationResponse
,HttpServletResponse
,ServletResponse
,Closeable
,Flushable
,AutoCloseable
- Direct Known Subclasses:
EmbeddedResponse
,HttpWebApplicationResponse
,NanoResponse
public class DefaultWebApplicationResponse
extends ServletOutputStream
implements WebApplicationResponse
The default WebApplicationResponse.
- Author:
- Manfred Riem ([email protected])
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Stores the body only flag.protected byte[]
Stores the buffer.protected boolean
Boolean indicating the buffer is resetting.protected String
Stores the character encoding.protected boolean
Stores if the character encoding has been set manually.protected boolean
Stores the committed flag.protected String
Stores the content languageprotected long
Stores the content length.protected String
Stores the content type.protected boolean
Stores if the content type has been set manually.Stores the cookies.protected boolean
Stores if we acquired the output stream.protected boolean
Stores if we acquired the writer.protected DefaultHttpHeaderManager
Stores the header manager.protected int
Stores the index.protected Locale
Stores the locale.protected OutputStream
Stores the output stream.protected Runnable
Stores the response closer.protected int
Stores the status code.protected String
Stores the status message.protected WebApplication
Stores the web application.protected PrintWriter
Stores the writer.Fields inherited from interface jakarta.servlet.http.HttpServletResponse
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the cookie.void
addDateHeader(String name, long date)
Add the date header.void
Add the header.void
addIntHeader(String name, int value)
Add the intheader.void
close()
void
Close the async response.boolean
containsHeader(String name)
Contains the header.encodeRedirectUrl(String url)
Deprecated.encodeRedirectURL(String url)
Encode the redirect URL.Deprecated.Encode the URL.void
flush()
void
Flush the buffer.int
Returns the buffer size.Returns the character encoding.long
Returns the content length.Returns the content type.Returns the cookies.Get the header.Returns the header names.getHeaders(String name)
Returns the headers.Returns the locale.Get the output stream.Returns the response closer.int
Returns the status.Returns the status message.Returns the underlying output stream.Returns the web application.Get the writer.boolean
Is body only.boolean
Is committed.boolean
isReady()
Is ready for output.void
reset()
Reset.void
Reset the buffer.void
sendError(int status)
Sends the error.void
Send the error.void
sendRedirect(String location)
Send a 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
Set the header.void
setIntHeader(String name, int value)
Set the int header.void
Set the locale.void
setOutputStream(ServletOutputStream outputStream)
Set the output stream.void
setResponseCloser(Runnable responseCloser)
Set the response closer.void
setStatus(int status)
Set the status.void
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)
void
Write the headers.void
Write the status line.Methods inherited from class jakarta.servlet.ServletOutputStream
print, print, print, print, print, print, print, println, println, println, println, println, println, println, println
Methods inherited from class java.io.OutputStream
nullOutputStream, write, write
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface jakarta.servlet.http.HttpServletResponse
getTrailerFields, setTrailerFields
-
Field Details
-
bodyOnly
protected boolean bodyOnlyStores the body only flag. -
buffer
protected byte[] bufferStores the buffer. -
bufferResetting
protected boolean bufferResettingBoolean indicating the buffer is resetting. When true, all output written will be ignored (thrown away). -
characterEncoding
Stores the character encoding. -
characterEncodingSet
protected boolean characterEncodingSetStores if the character encoding has been set manually. -
committed
protected boolean committedStores the committed flag. -
contentLength
protected long contentLengthStores the content length. -
contentType
Stores the content type. -
contentTypeSet
protected boolean contentTypeSetStores if the content type has been set manually. -
cookies
Stores the cookies. -
gotOutput
protected boolean gotOutputStores if we acquired the output stream. -
gotWriter
protected boolean gotWriterStores if we acquired the writer. -
headerManager
Stores the header manager. -
index
protected int indexStores the index. -
locale
Stores the locale. -
writer
Stores the writer. -
outputStream
Stores the output stream. -
status
protected int statusStores the status code. -
statusMessage
Stores the status message. -
webApplication
Stores the web application. -
contentLanguage
Stores the content language -
responseCloser
Stores the response closer.
-
-
Constructor Details
-
DefaultWebApplicationResponse
public DefaultWebApplicationResponse()Constructor.
-
-
Method Details
-
addCookie
Description copied from interface:HttpServletResponse
Adds the cookie.- Specified by:
addCookie
in interfaceHttpServletResponse
- Parameters:
cookie
- the cookie.
-
addDateHeader
Description copied from interface:HttpServletResponse
Add the date header.- Specified by:
addDateHeader
in interfaceHttpServletResponse
- Parameters:
name
- the name.date
- the date.
-
addHeader
Description copied from interface:HttpServletResponse
Add the header.- Specified by:
addHeader
in interfaceHttpServletResponse
- Parameters:
name
- the name.value
- the value.
-
addIntHeader
Description copied from interface:HttpServletResponse
Add the intheader.- Specified by:
addIntHeader
in interfaceHttpServletResponse
- Parameters:
name
- the name.value
- the value.
-
containsHeader
Description copied from interface:HttpServletResponse
Contains the header.- Specified by:
containsHeader
in interfaceHttpServletResponse
- Parameters:
name
- the name.- Returns:
- true if it contains the given header, false otherwise.
-
encodeRedirectURL
Description copied from interface:HttpServletResponse
Encode the redirect URL.- Specified by:
encodeRedirectURL
in interfaceHttpServletResponse
- Parameters:
url
- the redirect URL.- Returns:
- the encoded redirect URL.
-
encodeRedirectUrl
Deprecated.Description copied from interface:HttpServletResponse
Encode the redirect URL.- Specified by:
encodeRedirectUrl
in interfaceHttpServletResponse
- Parameters:
url
- the redirect URL.- Returns:
- the encoded redirect URL.
-
encodeURL
Description copied from interface:HttpServletResponse
Encode the URL.- Specified by:
encodeURL
in interfaceHttpServletResponse
- Parameters:
url
- the URL.- Returns:
- the encoded URL.
-
encodeUrl
Deprecated.Description copied from interface:HttpServletResponse
Encode the URL.- Specified by:
encodeUrl
in interfaceHttpServletResponse
- Parameters:
url
- the URL.- Returns:
- the encoded URL.
-
flushBuffer
Description copied from interface:ServletResponse
Flush the buffer.- Specified by:
flushBuffer
in interfaceServletResponse
- Throws:
IOException
- when an I/O error occurs.
-
getCharacterEncoding
Description copied from interface:ServletResponse
Returns the character encoding.- Specified by:
getCharacterEncoding
in interfaceServletResponse
- Returns:
- the character encoding
-
getBufferSize
public int getBufferSize()Description copied from interface:ServletResponse
Returns the buffer size.- Specified by:
getBufferSize
in interfaceServletResponse
- Returns:
- the buffer size
-
getContentLength
public long getContentLength()Returns the content length.- Returns:
- the content length
-
getContentType
Description copied from interface:ServletResponse
Returns the content type.- Specified by:
getContentType
in interfaceServletResponse
- Returns:
- the content type
-
getHeader
Description copied from interface:HttpServletResponse
Get the header.- Specified by:
getHeader
in interfaceHttpServletResponse
- Parameters:
name
- the name.- Returns:
- the value, or null if not found.
-
getHeaderNames
Description copied from interface:HttpServletResponse
Returns the header names.- Specified by:
getHeaderNames
in interfaceHttpServletResponse
- Returns:
- the header names
-
getHeaders
Description copied from interface:HttpServletResponse
Returns the headers.- Specified by:
getHeaders
in interfaceHttpServletResponse
- Parameters:
name
- the name.- Returns:
- the headers
-
getLocale
Description copied from interface:ServletResponse
Returns the locale.- Specified by:
getLocale
in interfaceServletResponse
- Returns:
- the locale
-
getOutputStream
Description copied from interface:ServletResponse
Get the output stream.- Specified by:
getOutputStream
in interfaceServletResponse
- Returns:
- the output stream.
- Throws:
IOException
- when an I/O error occurs.
-
getStatus
public int getStatus()Description copied from interface:HttpServletResponse
Returns the status.- Specified by:
getStatus
in interfaceHttpServletResponse
- Returns:
- the status
-
getStatusMessage
Returns the status message.- Returns:
- the status message
-
getWebApplication
Returns the web application.- Returns:
- the web application
-
getWriter
Description copied from interface:ServletResponse
Get the writer.- Specified by:
getWriter
in interfaceServletResponse
- Returns:
- the writer.
- Throws:
IOException
- when an I/O error occurs.
-
isBodyOnly
public boolean isBodyOnly()Is body only.- Returns:
- true if we are only sending the body, false otherwise.
-
isCommitted
public boolean isCommitted()Description copied from interface:ServletResponse
Is committed.- Specified by:
isCommitted
in interfaceServletResponse
- Returns:
- true if it is, false otherwise.
-
reset
public void reset()Description copied from interface:ServletResponse
Reset.- Specified by:
reset
in interfaceServletResponse
-
resetBuffer
public void resetBuffer()Description copied from interface:ServletResponse
Reset the buffer.- Specified by:
resetBuffer
in interfaceServletResponse
-
sendError
Description copied from interface:HttpServletResponse
Sends the error.- Specified by:
sendError
in interfaceHttpServletResponse
- Parameters:
status
- the status code.- Throws:
IOException
- when an I/O error occurs.
-
sendError
Description copied from interface:HttpServletResponse
Send the error.- Specified by:
sendError
in interfaceHttpServletResponse
- Parameters:
status
- the status code.statusMessage
- the message.- Throws:
IOException
- when an I/O error occurs.
-
sendRedirect
Description copied from interface:HttpServletResponse
Send a redirect.- Specified by:
sendRedirect
in interfaceHttpServletResponse
- Parameters:
location
- the location.- Throws:
IOException
- when an I/O error occurs.
-
setBodyOnly
public void setBodyOnly(boolean bodyOnly)Set the body only flag.- Parameters:
bodyOnly
- flag.
-
setBufferSize
public void setBufferSize(int bufferSize)Description copied from interface:ServletResponse
Set the buffer size.- Specified by:
setBufferSize
in interfaceServletResponse
- Parameters:
bufferSize
- the buffer size.
-
setCharacterEncoding
Description copied from interface:ServletResponse
Set the character encoding.- Specified by:
setCharacterEncoding
in interfaceServletResponse
- Parameters:
characterEncoding
- the character encoding.
-
setCommitted
public void setCommitted(boolean committed)Set the committed.- Parameters:
committed
- the committed flag.
-
setContentLength
public void setContentLength(int contentLength)Description copied from interface:ServletResponse
Set the content length.- Specified by:
setContentLength
in interfaceServletResponse
- Parameters:
contentLength
- the content length.
-
setContentLengthLong
public void setContentLengthLong(long contentLength)Description copied from interface:ServletResponse
Set the content length.- Specified by:
setContentLengthLong
in interfaceServletResponse
- Parameters:
contentLength
- the content length.
-
setContentType
Description copied from interface:ServletResponse
Set the content type.- Specified by:
setContentType
in interfaceServletResponse
- Parameters:
type
- the content type.
-
setDateHeader
Description copied from interface:HttpServletResponse
Set the date header.- Specified by:
setDateHeader
in interfaceHttpServletResponse
- Parameters:
name
- the name.date
- the date.
-
setHeader
Description copied from interface:HttpServletResponse
Set the header.- Specified by:
setHeader
in interfaceHttpServletResponse
- Parameters:
name
- the name.value
- the value.
-
setIntHeader
Description copied from interface:HttpServletResponse
Set the int header.- Specified by:
setIntHeader
in interfaceHttpServletResponse
- Parameters:
name
- the name.value
- the value.
-
setLocale
Description copied from interface:ServletResponse
Set the locale.- Specified by:
setLocale
in interfaceServletResponse
- Parameters:
locale
- the locale.
-
setOutputStream
Set the output stream.- Parameters:
outputStream
- the output stream.
-
setStatus
public void setStatus(int status)Description copied from interface:HttpServletResponse
Set the status.- Specified by:
setStatus
in interfaceHttpServletResponse
- Parameters:
status
- the status.
-
setStatus
Deprecated.Description copied from interface:HttpServletResponse
Set the status.- Specified by:
setStatus
in interfaceHttpServletResponse
- Parameters:
status
- the status.statusMessage
- the message.
-
setWebApplication
Description copied from interface:WebApplicationResponse
Set the web application.- Specified by:
setWebApplication
in interfaceWebApplicationResponse
- Parameters:
webApplication
- the web application.
-
verifyNotCommitted
Verify we are not committed.- Parameters:
methodName
- the method we are checking for.
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
closeAsyncResponse
public void closeAsyncResponse()Description copied from interface:WebApplicationResponse
Close the async response.- Specified by:
closeAsyncResponse
in interfaceWebApplicationResponse
-
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
getCookies
Description copied from interface:WebApplicationResponse
Returns the cookies.- Specified by:
getCookies
in interfaceWebApplicationResponse
- Returns:
- the cookies
-
getUnderlyingOutputStream
Description copied from interface:WebApplicationResponse
Returns the underlying output stream.- Specified by:
getUnderlyingOutputStream
in interfaceWebApplicationResponse
- Returns:
- the underlying output stream
-
isReady
public boolean isReady()Description copied from class:ServletOutputStream
Is ready for output.- Specified by:
isReady
in classServletOutputStream
- Returns:
- true if it is, false otherwise.
-
setUnderlyingOutputStream
Description copied from interface:WebApplicationResponse
Set the underlying output stream.- Specified by:
setUnderlyingOutputStream
in interfaceWebApplicationResponse
- Parameters:
outputStream
- the underlying output stream.
-
setWriteListener
Description copied from class:ServletOutputStream
Set the write listener.- Specified by:
setWriteListener
in classServletOutputStream
- Parameters:
listener
- the write listener.
-
write
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
writeHeaders
Description copied from interface:WebApplicationResponse
Write the headers.- Specified by:
writeHeaders
in interfaceWebApplicationResponse
- Throws:
IOException
- when an I/O error occurs.
-
writeStatusLine
Description copied from interface:WebApplicationResponse
Write the status line.- Specified by:
writeStatusLine
in interfaceWebApplicationResponse
- Throws:
IOException
- when an I/O error occurs.
-
getResponseCloser
Description copied from interface:WebApplicationResponse
Returns the response closer.- Specified by:
getResponseCloser
in interfaceWebApplicationResponse
- Returns:
- the response closer
-
setResponseCloser
Description copied from interface:WebApplicationResponse
Set the response closer.- Specified by:
setResponseCloser
in interfaceWebApplicationResponse
- Parameters:
responseCloser
- the response closer.
-