Class DefaultWebApplicationResponse

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 Details

    • bodyOnly

      protected boolean bodyOnly
      Stores the body only flag.
    • buffer

      protected byte[] buffer
      Stores the buffer.
    • bufferResetting

      protected boolean bufferResetting
      Boolean indicating the buffer is resetting. When true, all output written will be ignored (thrown away).
    • characterEncoding

      protected String characterEncoding
      Stores the character encoding.
    • characterEncodingSet

      protected boolean characterEncodingSet
      Stores if the character encoding has been set manually.
    • characterEncodingLocaleSet

      protected boolean characterEncodingLocaleSet
      Stores if the character encoding was set using setLocale.
    • committed

      protected boolean committed
      Stores the committed flag.
    • contentLength

      protected long contentLength
      Stores the content length.
    • contentType

      protected String contentType
      Stores the content type.
    • contentTypeSet

      protected boolean contentTypeSet
      Stores if the content type has been set manually.
    • cookies

      protected List<jakarta.servlet.http.Cookie> cookies
      Stores the cookies.
    • gotOutput

      protected boolean gotOutput
      Stores if we acquired the output stream.
    • gotWriter

      protected boolean gotWriter
      Stores if we acquired the writer.
    • headerManager

      protected DefaultHttpHeaderManager headerManager
      Stores the header manager.
    • index

      protected int index
      Stores the index.
    • locale

      protected Locale locale
      Stores the locale.
    • writer

      protected PrintWriter writer
      Stores the writer.
    • outputStream

      protected OutputStream outputStream
      Stores the output stream.
    • status

      protected int status
      Stores the status code.
    • statusMessage

      protected String statusMessage
      Stores the status message.
    • webApplication

      protected WebApplication webApplication
      Stores the web application.
    • contentLanguage

      protected String contentLanguage
      Stores the content language
    • responseCloser

      protected Runnable responseCloser
      Stores the response closer.
    • trailerFields

      protected Supplier<Map<String,String>> 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 interface jakarta.servlet.http.HttpServletResponse
    • addDateHeader

      public void addDateHeader(String name, long date)
      Specified by:
      addDateHeader in interface jakarta.servlet.http.HttpServletResponse
    • addHeader

      public void addHeader(String name, String value)
      Specified by:
      addHeader in interface jakarta.servlet.http.HttpServletResponse
    • addIntHeader

      public void addIntHeader(String name, int value)
      Specified by:
      addIntHeader in interface jakarta.servlet.http.HttpServletResponse
    • containsHeader

      public boolean containsHeader(String name)
      Specified by:
      containsHeader in interface jakarta.servlet.http.HttpServletResponse
    • encodeRedirectURL

      public String encodeRedirectURL(String url)
      Specified by:
      encodeRedirectURL in interface jakarta.servlet.http.HttpServletResponse
    • encodeURL

      public String encodeURL(String url)
      Specified by:
      encodeURL in interface jakarta.servlet.http.HttpServletResponse
    • flushBuffer

      public void flushBuffer() throws IOException
      Specified by:
      flushBuffer in interface jakarta.servlet.ServletResponse
      Throws:
      IOException
    • getCharacterEncoding

      public String getCharacterEncoding()
      Specified by:
      getCharacterEncoding in interface jakarta.servlet.ServletResponse
    • getBufferSize

      public int getBufferSize()
      Specified by:
      getBufferSize in interface jakarta.servlet.ServletResponse
    • getContentLength

      public long getContentLength()
      Returns the content length.
      Returns:
      the content length
    • getContentType

      public String getContentType()
      Specified by:
      getContentType in interface jakarta.servlet.ServletResponse
    • getHeader

      public String getHeader(String name)
      Specified by:
      getHeader in interface jakarta.servlet.http.HttpServletResponse
    • getHeaderNames

      public Collection<String> getHeaderNames()
      Specified by:
      getHeaderNames in interface jakarta.servlet.http.HttpServletResponse
    • getHeaders

      public Collection<String> getHeaders(String name)
      Specified by:
      getHeaders in interface jakarta.servlet.http.HttpServletResponse
    • getLocale

      public Locale getLocale()
      Specified by:
      getLocale in interface jakarta.servlet.ServletResponse
    • getOutputStream

      public jakarta.servlet.ServletOutputStream getOutputStream() throws IOException
      Specified by:
      getOutputStream in interface jakarta.servlet.ServletResponse
      Throws:
      IOException
    • getStatus

      public int getStatus()
      Specified by:
      getStatus in interface jakarta.servlet.http.HttpServletResponse
    • getStatusMessage

      public String getStatusMessage()
      Returns the status message.
      Returns:
      the status message
    • getWebApplication

      public WebApplication getWebApplication()
      Returns the web application.
      Returns:
      the web application
    • getWriter

      public PrintWriter getWriter() throws IOException
      Specified by:
      getWriter in interface jakarta.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 interface jakarta.servlet.ServletResponse
    • reset

      public void reset()
      Specified by:
      reset in interface jakarta.servlet.ServletResponse
    • resetBuffer

      public void resetBuffer()
      Specified by:
      resetBuffer in interface jakarta.servlet.ServletResponse
    • sendError

      public void sendError(int status) throws IOException
      Specified by:
      sendError in interface jakarta.servlet.http.HttpServletResponse
      Throws:
      IOException
    • sendError

      public void sendError(int status, String statusMessage) throws IOException
      Specified by:
      sendError in interface jakarta.servlet.http.HttpServletResponse
      Throws:
      IOException
    • sendRedirect

      public void sendRedirect(String location) throws IOException
      Specified by:
      sendRedirect in interface jakarta.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 interface jakarta.servlet.ServletResponse
    • setCharacterEncoding

      public void setCharacterEncoding(String characterEncoding)
      Specified by:
      setCharacterEncoding in interface jakarta.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 interface jakarta.servlet.ServletResponse
    • setContentLengthLong

      public void setContentLengthLong(long contentLength)
      Specified by:
      setContentLengthLong in interface jakarta.servlet.ServletResponse
    • setContentType

      public void setContentType(String type)
      Specified by:
      setContentType in interface jakarta.servlet.ServletResponse
    • setDateHeader

      public void setDateHeader(String name, long date)
      Specified by:
      setDateHeader in interface jakarta.servlet.http.HttpServletResponse
    • setHeader

      public void setHeader(String name, String value)
      Specified by:
      setHeader in interface jakarta.servlet.http.HttpServletResponse
    • setIntHeader

      public void setIntHeader(String name, int value)
      Specified by:
      setIntHeader in interface jakarta.servlet.http.HttpServletResponse
    • setLocale

      public void setLocale(Locale locale)
      Specified by:
      setLocale in interface jakarta.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 interface jakarta.servlet.http.HttpServletResponse
    • setWebApplication

      public void setWebApplication(WebApplication webApplication)
      Description copied from interface: WebApplicationResponse
      Set the web application.
      Specified by:
      setWebApplication in interface WebApplicationResponse
      Parameters:
      webApplication - the web application.
    • verifyNotCommitted

      protected void verifyNotCommitted(String methodName)
      Verify we are not committed.
      Parameters:
      methodName - the method we are checking for.
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OutputStream
      Throws:
      IOException
    • closeAsyncResponse

      public void closeAsyncResponse()
      Description copied from interface: WebApplicationResponse
      Close the async response.
      Specified by:
      closeAsyncResponse in interface WebApplicationResponse
    • flush

      public void flush() throws IOException
      Specified by:
      flush in interface Flushable
      Overrides:
      flush in class OutputStream
      Throws:
      IOException
    • getCookies

      public Collection<jakarta.servlet.http.Cookie> getCookies()
      Description copied from interface: WebApplicationResponse
      Returns the cookies.
      Specified by:
      getCookies in interface WebApplicationResponse
      Returns:
      the cookies
    • getUnderlyingOutputStream

      public OutputStream getUnderlyingOutputStream()
      Description copied from interface: WebApplicationResponse
      Returns the underlying output stream.
      Specified by:
      getUnderlyingOutputStream in interface WebApplicationResponse
      Returns:
      the underlying output stream
    • isReady

      public boolean isReady()
      Specified by:
      isReady in class jakarta.servlet.ServletOutputStream
    • setUnderlyingOutputStream

      public final void setUnderlyingOutputStream(OutputStream outputStream)
      Description copied from interface: WebApplicationResponse
      Set the underlying output stream.
      Specified by:
      setUnderlyingOutputStream in interface WebApplicationResponse
      Parameters:
      outputStream - the underlying output stream.
    • setWriteListener

      public void setWriteListener(jakarta.servlet.WriteListener listener)
      Specified by:
      setWriteListener in class jakarta.servlet.ServletOutputStream
    • write

      public void write(int integer) throws IOException
      Specified by:
      write in class OutputStream
      Throws:
      IOException
    • writeHeaders

      public void writeHeaders() throws IOException
      Description copied from interface: WebApplicationResponse
      Write the headers.
      Specified by:
      writeHeaders in interface WebApplicationResponse
      Throws:
      IOException - when an I/O error occurs.
    • getResponseCloser

      public Runnable getResponseCloser()
      Description copied from interface: WebApplicationResponse
      Returns the response closer.
      Specified by:
      getResponseCloser in interface WebApplicationResponse
      Returns:
      the response closer
    • getTrailerFields

      public Supplier<Map<String,String>> getTrailerFields()
      Specified by:
      getTrailerFields in interface jakarta.servlet.http.HttpServletResponse
    • setResponseCloser

      public void setResponseCloser(Runnable responseCloser)
      Description copied from interface: WebApplicationResponse
      Set the response closer.
      Specified by:
      setResponseCloser in interface WebApplicationResponse
      Parameters:
      responseCloser - the response closer.
    • setTrailerFields

      public void setTrailerFields(Supplier<Map<String,String>> trailerFields)
      Specified by:
      setTrailerFields in interface jakarta.servlet.http.HttpServletResponse
    • writeStatusLine

      public void writeStatusLine() throws IOException
      Description copied from interface: WebApplicationResponse
      Write the status line.
      Specified by:
      writeStatusLine in interface WebApplicationResponse
      Throws:
      IOException - when an I/O error occurs.