Interface AtmosphereResponse

All Superinterfaces:
jakarta.servlet.http.HttpServletResponse, jakarta.servlet.ServletResponse
All Known Implementing Classes:
AtmosphereResponseImpl

public interface AtmosphereResponse extends jakarta.servlet.http.HttpServletResponse
An Atmosphere's response representation. An AtmosphereResponse can be used to construct a bi-directional asynchronous application. If the underlying transport is a WebSocket or if its associated AtmosphereResource has been suspended, this object can be used to write message back to the client at any moment.
This object can delegate the write operation to AsyncIOWriter.
Author:
Jeanfrancois Arcand
  • Method Details

    • destroy

      void destroy()
    • destroy

      void destroy(boolean force)
    • destroyed

      boolean destroyed()
    • addCookie

      void addCookie(jakarta.servlet.http.Cookie cookie)
      Specified by:
      addCookie in interface jakarta.servlet.http.HttpServletResponse
    • containsHeader

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

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

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

      String encodeUrl(String url)
      Specified by:
      encodeUrl in interface jakarta.servlet.http.HttpServletResponse
    • encodeRedirectUrl

      String encodeRedirectUrl(String url)
      Specified by:
      encodeRedirectUrl in interface jakarta.servlet.http.HttpServletResponse
    • delegateToNativeResponse

      AtmosphereResponse delegateToNativeResponse(boolean delegateToNativeResponse)
    • sendError

      void sendError(int sc, String msg) throws IOException
      Specified by:
      sendError in interface jakarta.servlet.http.HttpServletResponse
      Throws:
      IOException
    • sendError

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

      void sendRedirect(String location) throws IOException
      Specified by:
      sendRedirect in interface jakarta.servlet.http.HttpServletResponse
      Throws:
      IOException
    • setDateHeader

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

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

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

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

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

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

      void setStatus(int status)
      Specified by:
      setStatus in interface jakarta.servlet.http.HttpServletResponse
    • setStatus

      void setStatus(int status, String statusMessage)
      Specified by:
      setStatus in interface jakarta.servlet.http.HttpServletResponse
    • getStatus

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

      jakarta.servlet.ServletResponse getResponse()
    • getStatusMessage

      String getStatusMessage()
    • headers

      Map<String,String> headers()
    • getHeader

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

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

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

      void setCharacterEncoding(String charSet)
      Specified by:
      setCharacterEncoding in interface jakarta.servlet.ServletResponse
    • flushBuffer

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

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

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

      boolean isDestroyable()
      Check if this object can be destroyed. Default is true.
    • destroyable

      AtmosphereResponse destroyable(boolean destroyable)
    • getOutputStream

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

      PrintWriter getWriter() throws IOException
      Specified by:
      getWriter in interface jakarta.servlet.ServletResponse
      Throws:
      IOException
    • setContentLength

      void setContentLength(int len)
      Specified by:
      setContentLength in interface jakarta.servlet.ServletResponse
    • setContentType

      void setContentType(String contentType)
      Specified by:
      setContentType in interface jakarta.servlet.ServletResponse
    • getContentType

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

      boolean isCommitted()
      Specified by:
      isCommitted in interface jakarta.servlet.ServletResponse
    • reset

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

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

      void setBufferSize(int size)
      Specified by:
      setBufferSize in interface jakarta.servlet.ServletResponse
    • setLocale

      void setLocale(Locale locale)
      Specified by:
      setLocale in interface jakarta.servlet.ServletResponse
    • getLocale

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

      AsyncIOWriter getAsyncIOWriter()
      Return the underlying AsyncIOWriter.
    • asyncIOWriter

      AtmosphereResponse asyncIOWriter(AsyncIOWriter asyncIOWriter)
      Set an implementation of AsyncIOWriter that will be invoked every time a write operation is ready to be processed.
      Parameters:
      asyncIOWriter - of AsyncIOWriter
      Returns:
      this
    • request

      Return the associated AtmosphereRequest.
      Returns:
      the associated AtmosphereRequest
    • request

      AtmosphereResponse request(AtmosphereRequest atmosphereRequest)
      Set the associated AtmosphereRequest.
      Parameters:
      atmosphereRequest - a AtmosphereRequest
      Returns:
      this
    • close

      void close() throws IOException
      Close the associated AsyncIOWriter.
      Throws:
      IOException
    • closeStreamOrWriter

      void closeStreamOrWriter()
      Close the associated PrintWriter or OutputStream
    • write

      Write the String by either using the PrintWriter or OutputStream. The decision is based on the request attribute ApplicationConfig.PROPERTY_USE_STREAM
      Parameters:
      data - the String to write
    • write

      AtmosphereResponse write(String data, boolean writeUsingOriginalResponse)
      Write the String by either using the PrintWriter or OutputStream. The decision is based on the request attribute ApplicationConfig.PROPERTY_USE_STREAM. If writeUsingOriginalResponse is set to true, execute the write without invoking the defined AsyncIOWriter.
      Parameters:
      data - the String to write
      writeUsingOriginalResponse - if true, execute the write without invoking the AsyncIOWriter
    • write

      AtmosphereResponse write(byte[] data)
      Write the bytes by either using the PrintWriter or OutputStream. The decision is based on the request attribute ApplicationConfig.PROPERTY_USE_STREAM.
      Parameters:
      data - the bytes to write
    • write

      AtmosphereResponse write(byte[] data, boolean writeUsingOriginalResponse)
      Write the String by either using the PrintWriter or OutputStream. The decision is based on the request attribute ApplicationConfig.PROPERTY_USE_STREAM. If writeUsingOriginalResponse is set to true, execute the write without invoking the defined AsyncIOWriter.
      Parameters:
      data - the bytes to write
      writeUsingOriginalResponse - if true, execute the write without invoking the AsyncIOWriter
    • write

      AtmosphereResponse write(byte[] data, int offset, int length)
      Write the bytes by either using the PrintWriter or OutputStream. The decision is based on the request attribute ApplicationConfig.PROPERTY_USE_STREAM.
      Parameters:
      data - the bytes to write
      offset - the first byte position to write
      length - the data length
    • write

      AtmosphereResponse write(byte[] data, int offset, int length, boolean writeUsingOriginalResponse)
      Write the String by either using the PrintWriter or OutputStream. The decision is based on the request attribute ApplicationConfig.PROPERTY_USE_STREAM. If writeUsingOriginalResponse is set to true, execute the write without invoking the defined AsyncIOWriter.
      Parameters:
      data - the bytes to write
      offset - the first byte position to write
      length - the data length
      writeUsingOriginalResponse - if true, execute the write without invoking the AsyncIOWriter
    • resource

      AtmosphereResource resource()
      The AtmosphereResource associated with this request. If the request hasn't been suspended, this method will return null.
      Returns:
      an AtmosphereResource, or null.
    • setResponse

      void setResponse(jakarta.servlet.ServletResponse response)
    • uuid

      String uuid()
      Return the AtmosphereResource.uuid() used by this object.
      Returns:
      the AtmosphereResource.uuid() used by this object.
    • toString

      String toString()
      Overrides:
      toString in class Object