java.lang.Object
java.io.OutputStream
jakarta.servlet.ServletOutputStream
cloud.piranha.core.impl.DefaultWebApplicationResponse
- All Implemented Interfaces:
WebApplicationResponse
,jakarta.servlet.http.HttpServletResponse
,jakarta.servlet.ServletResponse
,Closeable
,Flushable
,AutoCloseable
- Direct Known Subclasses:
EmbeddedResponse
,HttpWebApplicationResponse
public class DefaultWebApplicationResponse
extends jakarta.servlet.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 was set using setLocale.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.protected List<jakarta.servlet.http.Cookie>
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.Stores the trailer fields supplier.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
addCookie
(jakarta.servlet.http.Cookie cookie) void
addDateHeader
(String name, long date) void
void
addIntHeader
(String name, int value) void
close()
void
Close the async response.boolean
containsHeader
(String name) encodeRedirectURL
(String url) void
flush()
void
int
long
Returns the content length.Collection<jakarta.servlet.http.Cookie>
Returns the cookies.getHeaders
(String name) jakarta.servlet.ServletOutputStream
Returns the response closer.int
Returns the status message.Returns the underlying output stream.Returns the web application.boolean
Is body only.boolean
boolean
isReady()
void
reset()
void
void
sendError
(int status) void
void
sendRedirect
(String location) void
setBodyOnly
(boolean bodyOnly) Set the body only flag.void
setBufferSize
(int bufferSize) void
setCharacterEncoding
(String characterEncoding) void
setCommitted
(boolean committed) Set the committed.void
setContentLength
(int contentLength) void
setContentLengthLong
(long contentLength) void
setContentType
(String type) void
setDateHeader
(String name, long date) void
void
setIntHeader
(String name, int value) void
void
setOutputStream
(jakarta.servlet.ServletOutputStream outputStream) Set the output stream.void
setResponseCloser
(Runnable responseCloser) Set the response closer.void
setStatus
(int status) void
setTrailerFields
(Supplier<Map<String, String>> trailerFields) final void
setUnderlyingOutputStream
(OutputStream outputStream) Set the underlying output stream.void
setWebApplication
(WebApplication webApplication) Set the web application.void
setWriteListener
(jakarta.servlet.WriteListener 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
-
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. -
characterEncodingLocaleSet
protected boolean characterEncodingLocaleSetStores if the character encoding was set using setLocale. -
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. -
trailerFields
Stores the trailer fields supplier.
-
-
Constructor Details
-
DefaultWebApplicationResponse
public DefaultWebApplicationResponse()Constructor.
-
-
Method Details
-
addCookie
public void addCookie(jakarta.servlet.http.Cookie cookie) - Specified by:
addCookie
in interfacejakarta.servlet.http.HttpServletResponse
-
addDateHeader
- Specified by:
addDateHeader
in interfacejakarta.servlet.http.HttpServletResponse
-
addHeader
- Specified by:
addHeader
in interfacejakarta.servlet.http.HttpServletResponse
-
addIntHeader
- Specified by:
addIntHeader
in interfacejakarta.servlet.http.HttpServletResponse
-
containsHeader
- Specified by:
containsHeader
in interfacejakarta.servlet.http.HttpServletResponse
-
encodeRedirectURL
- Specified by:
encodeRedirectURL
in interfacejakarta.servlet.http.HttpServletResponse
-
encodeURL
- Specified by:
encodeURL
in interfacejakarta.servlet.http.HttpServletResponse
-
flushBuffer
- Specified by:
flushBuffer
in interfacejakarta.servlet.ServletResponse
- Throws:
IOException
-
getCharacterEncoding
- Specified by:
getCharacterEncoding
in interfacejakarta.servlet.ServletResponse
-
getBufferSize
public int getBufferSize()- Specified by:
getBufferSize
in interfacejakarta.servlet.ServletResponse
-
getContentLength
public long getContentLength()Returns the content length.- Returns:
- the content length
-
getContentType
- Specified by:
getContentType
in interfacejakarta.servlet.ServletResponse
-
getHeader
- Specified by:
getHeader
in interfacejakarta.servlet.http.HttpServletResponse
-
getHeaderNames
- Specified by:
getHeaderNames
in interfacejakarta.servlet.http.HttpServletResponse
-
getHeaders
- Specified by:
getHeaders
in interfacejakarta.servlet.http.HttpServletResponse
-
getLocale
- Specified by:
getLocale
in interfacejakarta.servlet.ServletResponse
-
getOutputStream
- Specified by:
getOutputStream
in interfacejakarta.servlet.ServletResponse
- Throws:
IOException
-
getStatus
public int getStatus()- Specified by:
getStatus
in interfacejakarta.servlet.http.HttpServletResponse
-
getStatusMessage
Returns the status message.- Returns:
- the status message
-
getWebApplication
Returns the web application.- Returns:
- the web application
-
getWriter
- Specified by:
getWriter
in interfacejakarta.servlet.ServletResponse
- Throws:
IOException
-
isBodyOnly
public boolean isBodyOnly()Is body only.- Returns:
- true if we are only sending the body, false otherwise.
-
isCommitted
public boolean isCommitted()- Specified by:
isCommitted
in interfacejakarta.servlet.ServletResponse
-
reset
public void reset()- Specified by:
reset
in interfacejakarta.servlet.ServletResponse
-
resetBuffer
public void resetBuffer()- Specified by:
resetBuffer
in interfacejakarta.servlet.ServletResponse
-
sendError
- Specified by:
sendError
in interfacejakarta.servlet.http.HttpServletResponse
- Throws:
IOException
-
sendError
- Specified by:
sendError
in interfacejakarta.servlet.http.HttpServletResponse
- Throws:
IOException
-
sendRedirect
- Specified by:
sendRedirect
in interfacejakarta.servlet.http.HttpServletResponse
- Throws:
IOException
-
setBodyOnly
public void setBodyOnly(boolean bodyOnly) Set the body only flag.- Parameters:
bodyOnly
- flag.
-
setBufferSize
public void setBufferSize(int bufferSize) - Specified by:
setBufferSize
in interfacejakarta.servlet.ServletResponse
-
setCharacterEncoding
- Specified by:
setCharacterEncoding
in interfacejakarta.servlet.ServletResponse
-
setCommitted
public void setCommitted(boolean committed) Set the committed.- Parameters:
committed
- the committed flag.
-
setContentLength
public void setContentLength(int contentLength) - Specified by:
setContentLength
in interfacejakarta.servlet.ServletResponse
-
setContentLengthLong
public void setContentLengthLong(long contentLength) - Specified by:
setContentLengthLong
in interfacejakarta.servlet.ServletResponse
-
setContentType
- Specified by:
setContentType
in interfacejakarta.servlet.ServletResponse
-
setDateHeader
- Specified by:
setDateHeader
in interfacejakarta.servlet.http.HttpServletResponse
-
setHeader
- Specified by:
setHeader
in interfacejakarta.servlet.http.HttpServletResponse
-
setIntHeader
- Specified by:
setIntHeader
in interfacejakarta.servlet.http.HttpServletResponse
-
setLocale
- Specified by:
setLocale
in interfacejakarta.servlet.ServletResponse
-
setOutputStream
public void setOutputStream(jakarta.servlet.ServletOutputStream outputStream) Set the output stream.- Parameters:
outputStream
- the output stream.
-
setStatus
public void setStatus(int status) - Specified by:
setStatus
in interfacejakarta.servlet.http.HttpServletResponse
-
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()- Specified by:
isReady
in classjakarta.servlet.ServletOutputStream
-
setUnderlyingOutputStream
Description copied from interface:WebApplicationResponse
Set the underlying output stream.- Specified by:
setUnderlyingOutputStream
in interfaceWebApplicationResponse
- Parameters:
outputStream
- the underlying output stream.
-
setWriteListener
public void setWriteListener(jakarta.servlet.WriteListener listener) - Specified by:
setWriteListener
in classjakarta.servlet.ServletOutputStream
-
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.
-
getResponseCloser
Description copied from interface:WebApplicationResponse
Returns the response closer.- Specified by:
getResponseCloser
in interfaceWebApplicationResponse
- Returns:
- the response closer
-
getTrailerFields
- Specified by:
getTrailerFields
in interfacejakarta.servlet.http.HttpServletResponse
-
setResponseCloser
Description copied from interface:WebApplicationResponse
Set the response closer.- Specified by:
setResponseCloser
in interfaceWebApplicationResponse
- Parameters:
responseCloser
- the response closer.
-
setTrailerFields
- Specified by:
setTrailerFields
in interfacejakarta.servlet.http.HttpServletResponse
-
writeStatusLine
Description copied from interface:WebApplicationResponse
Write the status line.- Specified by:
writeStatusLine
in interfaceWebApplicationResponse
- Throws:
IOException
- when an I/O error occurs.
-