Package org.atmosphere.cpr
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
This object can delegate the write operation to
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
-
Nested Class Summary
Nested Classes -
Field Summary
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCookie(jakarta.servlet.http.Cookie cookie) voidaddDateHeader(String name, long date) voidvoidaddIntHeader(String name, int value) asyncIOWriter(AsyncIOWriter asyncIOWriter) Set an implementation ofAsyncIOWriterthat will be invoked every time a write operation is ready to be processed.voidclose()Close the associatedAsyncIOWriter.voidClose the associatedPrintWriterorOutputStreambooleancontainsHeader(String name) delegateToNativeResponse(boolean delegateToNativeResponse) voiddestroy()voiddestroy(boolean force) destroyable(boolean destroyable) booleanencodeRedirectUrl(String url) encodeRedirectURL(String url) voidReturn the underlyingAsyncIOWriter.intgetHeaders(String name) jakarta.servlet.ServletOutputStreamjakarta.servlet.ServletResponseintheaders()booleanbooleanCheck if this object can be destroyed.request()Return the associatedAtmosphereRequest.request(AtmosphereRequest atmosphereRequest) Set the associatedAtmosphereRequest.voidreset()voidresource()TheAtmosphereResourceassociated with this request.voidsendError(int sc) voidvoidsendRedirect(String location) voidsetBufferSize(int size) voidsetCharacterEncoding(String charSet) voidsetContentLength(int len) voidsetContentType(String contentType) voidsetDateHeader(String name, long date) voidvoidsetIntHeader(String name, int value) voidvoidsetResponse(jakarta.servlet.ServletResponse response) voidsetStatus(int status) voidtoString()uuid()Return theAtmosphereResource.uuid()used by this object.write(byte[] data) Write the bytes by either using thePrintWriterorOutputStream.write(byte[] data, boolean writeUsingOriginalResponse) Write the String by either using thePrintWriterorOutputStream.write(byte[] data, int offset, int length) Write the bytes by either using thePrintWriterorOutputStream.write(byte[] data, int offset, int length, boolean writeUsingOriginalResponse) Write the String by either using thePrintWriterorOutputStream.Write the String by either using thePrintWriterorOutputStream.Write the String by either using thePrintWriterorOutputStream.Methods inherited from interface jakarta.servlet.http.HttpServletResponse
getTrailerFields, setTrailerFieldsMethods inherited from interface jakarta.servlet.ServletResponse
setContentLengthLong
-
Method Details
-
destroy
void destroy() -
destroy
void destroy(boolean force) -
destroyed
boolean destroyed() -
addCookie
void addCookie(jakarta.servlet.http.Cookie cookie) - Specified by:
addCookiein interfacejakarta.servlet.http.HttpServletResponse
-
containsHeader
- Specified by:
containsHeaderin interfacejakarta.servlet.http.HttpServletResponse
-
encodeURL
- Specified by:
encodeURLin interfacejakarta.servlet.http.HttpServletResponse
-
encodeRedirectURL
- Specified by:
encodeRedirectURLin interfacejakarta.servlet.http.HttpServletResponse
-
encodeUrl
- Specified by:
encodeUrlin interfacejakarta.servlet.http.HttpServletResponse
-
encodeRedirectUrl
- Specified by:
encodeRedirectUrlin interfacejakarta.servlet.http.HttpServletResponse
-
delegateToNativeResponse
-
sendError
- Specified by:
sendErrorin interfacejakarta.servlet.http.HttpServletResponse- Throws:
IOException
-
sendError
- Specified by:
sendErrorin interfacejakarta.servlet.http.HttpServletResponse- Throws:
IOException
-
sendRedirect
- Specified by:
sendRedirectin interfacejakarta.servlet.http.HttpServletResponse- Throws:
IOException
-
setDateHeader
- Specified by:
setDateHeaderin interfacejakarta.servlet.http.HttpServletResponse
-
addDateHeader
- Specified by:
addDateHeaderin interfacejakarta.servlet.http.HttpServletResponse
-
setHeader
- Specified by:
setHeaderin interfacejakarta.servlet.http.HttpServletResponse
-
addHeader
- Specified by:
addHeaderin interfacejakarta.servlet.http.HttpServletResponse
-
setIntHeader
- Specified by:
setIntHeaderin interfacejakarta.servlet.http.HttpServletResponse
-
addIntHeader
- Specified by:
addIntHeaderin interfacejakarta.servlet.http.HttpServletResponse
-
setStatus
void setStatus(int status) - Specified by:
setStatusin interfacejakarta.servlet.http.HttpServletResponse
-
setStatus
- Specified by:
setStatusin interfacejakarta.servlet.http.HttpServletResponse
-
getStatus
int getStatus()- Specified by:
getStatusin interfacejakarta.servlet.http.HttpServletResponse
-
getResponse
jakarta.servlet.ServletResponse getResponse() -
getStatusMessage
String getStatusMessage() -
headers
-
getHeader
- Specified by:
getHeaderin interfacejakarta.servlet.http.HttpServletResponse
-
getHeaders
- Specified by:
getHeadersin interfacejakarta.servlet.http.HttpServletResponse
-
getHeaderNames
Collection<String> getHeaderNames()- Specified by:
getHeaderNamesin interfacejakarta.servlet.http.HttpServletResponse
-
setCharacterEncoding
- Specified by:
setCharacterEncodingin interfacejakarta.servlet.ServletResponse
-
flushBuffer
- Specified by:
flushBufferin interfacejakarta.servlet.ServletResponse- Throws:
IOException
-
getBufferSize
int getBufferSize()- Specified by:
getBufferSizein interfacejakarta.servlet.ServletResponse
-
getCharacterEncoding
String getCharacterEncoding()- Specified by:
getCharacterEncodingin interfacejakarta.servlet.ServletResponse
-
isDestroyable
boolean isDestroyable()Check if this object can be destroyed. Default is true. -
destroyable
-
getOutputStream
- Specified by:
getOutputStreamin interfacejakarta.servlet.ServletResponse- Throws:
IOException
-
getWriter
- Specified by:
getWriterin interfacejakarta.servlet.ServletResponse- Throws:
IOException
-
setContentLength
void setContentLength(int len) - Specified by:
setContentLengthin interfacejakarta.servlet.ServletResponse
-
setContentType
- Specified by:
setContentTypein interfacejakarta.servlet.ServletResponse
-
getContentType
String getContentType()- Specified by:
getContentTypein interfacejakarta.servlet.ServletResponse
-
isCommitted
boolean isCommitted()- Specified by:
isCommittedin interfacejakarta.servlet.ServletResponse
-
reset
void reset()- Specified by:
resetin interfacejakarta.servlet.ServletResponse
-
resetBuffer
void resetBuffer()- Specified by:
resetBufferin interfacejakarta.servlet.ServletResponse
-
setBufferSize
void setBufferSize(int size) - Specified by:
setBufferSizein interfacejakarta.servlet.ServletResponse
-
setLocale
- Specified by:
setLocalein interfacejakarta.servlet.ServletResponse
-
getLocale
Locale getLocale()- Specified by:
getLocalein interfacejakarta.servlet.ServletResponse
-
getAsyncIOWriter
AsyncIOWriter getAsyncIOWriter()Return the underlyingAsyncIOWriter. -
asyncIOWriter
Set an implementation ofAsyncIOWriterthat will be invoked every time a write operation is ready to be processed.- Parameters:
asyncIOWriter- ofAsyncIOWriter- Returns:
- this
-
request
AtmosphereRequest request()Return the associatedAtmosphereRequest.- Returns:
- the associated
AtmosphereRequest
-
request
Set the associatedAtmosphereRequest.- Parameters:
atmosphereRequest- aAtmosphereRequest- Returns:
- this
-
close
Close the associatedAsyncIOWriter.- Throws:
IOException
-
closeStreamOrWriter
void closeStreamOrWriter()Close the associatedPrintWriterorOutputStream -
write
Write the String by either using thePrintWriterorOutputStream. The decision is based on the request attributeApplicationConfig.PROPERTY_USE_STREAM- Parameters:
data- the String to write
-
write
Write the String by either using thePrintWriterorOutputStream. The decision is based on the request attributeApplicationConfig.PROPERTY_USE_STREAM. If writeUsingOriginalResponse is set to true, execute the write without invoking the definedAsyncIOWriter.- Parameters:
data- the String to writewriteUsingOriginalResponse- if true, execute the write without invoking theAsyncIOWriter
-
write
Write the bytes by either using thePrintWriterorOutputStream. The decision is based on the request attributeApplicationConfig.PROPERTY_USE_STREAM.- Parameters:
data- the bytes to write
-
write
Write the String by either using thePrintWriterorOutputStream. The decision is based on the request attributeApplicationConfig.PROPERTY_USE_STREAM. If writeUsingOriginalResponse is set to true, execute the write without invoking the definedAsyncIOWriter.- Parameters:
data- the bytes to writewriteUsingOriginalResponse- if true, execute the write without invoking theAsyncIOWriter
-
write
Write the bytes by either using thePrintWriterorOutputStream. The decision is based on the request attributeApplicationConfig.PROPERTY_USE_STREAM.- Parameters:
data- the bytes to writeoffset- the first byte position to writelength- the data length
-
write
Write the String by either using thePrintWriterorOutputStream. The decision is based on the request attributeApplicationConfig.PROPERTY_USE_STREAM. If writeUsingOriginalResponse is set to true, execute the write without invoking the definedAsyncIOWriter.- Parameters:
data- the bytes to writeoffset- the first byte position to writelength- the data lengthwriteUsingOriginalResponse- if true, execute the write without invoking theAsyncIOWriter
-
resource
AtmosphereResource resource()TheAtmosphereResourceassociated 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 theAtmosphereResource.uuid()used by this object.- Returns:
- the
AtmosphereResource.uuid()used by this object.
-
toString
String toString()
-