Interface IResponse
- All Known Subinterfaces:
IResponse
public interface IResponse
Interface that the webcontainer expects the response objects to implement. The methods
on this interface will be called by the webcontainer in the process of writing back
the response.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCookie
(jakarta.servlet.http.Cookie cookie) Add a cookie to the response.void
addDateHeader
(String name, long t) Add a header as a long valuevoid
addHeader
(byte[] name, byte[] value) Add a headervoid
Add a headervoid
addIntHeader
(String name, int i) Add a header as an int valuevoid
Clears the headers datastructureboolean
containsHeader
(byte[] name) Returns true if the header with the supplied name is already presentboolean
containsHeader
(String name) Returns true is the header with the supplied name is already presentvoid
void
Flushes the contents to wireint
jakarta.servlet.http.Cookie[]
Get all the cookies for the responseboolean
Gets the flush mode.getHeader
(byte[] name) Get a headerGet a headerGets all the header names (keys)getHeaders
(String name) Gets all the header values for a particular header nameVector[]
Get the header tablejakarta.servlet.ServletOutputStream
Get the OutputStreamGet the webcontainer channel request object for this responseboolean
Get whether to allocate direct or indirect byte buffersboolean
Check if the response is committed yetvoid
Prepare to write the headersvoid
void
removeCookie
(String cookieName) void
removeHeader
(byte[] name) Removes the header with the given namevoid
removeHeader
(String name) Removes the header with the given namevoid
void
setAllocateDirect
(boolean allocateDirect) Set whether to allocate direct or indirect byte buffersvoid
setBufferSize
(int bufferSize) void
setContentLanguage
(byte[] value) Set the content language for the responsevoid
setContentLanguage
(String value) Set the content language for the responsevoid
setContentLength
(int length) Set the content length for the responsevoid
setContentType
(byte[] value) Set the content type for the responsevoid
setContentType
(String value) Set the content type for the responsevoid
setDateHeader
(String name, long t) Set date header as a long valuevoid
setFlushMode
(boolean flushToWire) Sets the flush mode.void
setHeader
(byte[] name, byte[] bs) void
void
setIntHeader
(String name, int i) Set a header as an intvoid
setIsClosing
(boolean isClosing) void
setLastBuffer
(boolean writeLastBuffer) Set the last buffer modevoid
setReason
(byte[] reason) Sets the reason in the response.void
Sets the reason in the response.void
setStatusCode
(int code) Sets the HTTP status codevoid
Write the headers
-
Method Details
-
setStatusCode
void setStatusCode(int code) Sets the HTTP status code- Parameters:
code
- the HTTP status code
-
getOutputStream
Get the OutputStream- Returns:
- OutputStream the output stream
- Throws:
IOException
-
isCommitted
boolean isCommitted()Check if the response is committed yet- Returns:
- boolean whether or not the response is committed
-
addHeader
Add a header- Parameters:
name
- the name of the headername
- the value of the header
-
addHeader
void addHeader(byte[] name, byte[] value) Add a header- Parameters:
name
- the name of the headervalue
- the value of the header
-
addDateHeader
Add a header as a long value- Parameters:
name
- the header namet
- the header date value
-
addIntHeader
Add a header as an int value- Parameters:
name
- the header namei
- the header int value
-
setDateHeader
Set date header as a long value- Parameters:
name
- the header namet
- the header date value
-
setIntHeader
Set a header as an int- Parameters:
name
- the header namei
- the header int value
-
getHeaderNames
Enumeration getHeaderNames()Gets all the header names (keys)- Returns:
- Collection of header names
-
getHeaders
Gets all the header values for a particular header name- Returns:
- Collection of header v
-
getHeader
Get a header- Parameters:
name
- the header name- Returns:
- String the header value
-
getHeaderTable
Vector[] getHeaderTable()Get the header table- Returns:
- Vector the header names
-
getHeader
Get a header- Parameters:
name
- the header name- Returns:
- String the header value
-
containsHeader
Returns true is the header with the supplied name is already present- Parameters:
name
- the header name- Returns:
- boolean whether the header is present
-
containsHeader
boolean containsHeader(byte[] name) Returns true if the header with the supplied name is already present- Parameters:
name
- the header name- Returns:
- boolean whether the header is present
-
removeHeader
Removes the header with the given name- Parameters:
name
- the header name
-
removeHeader
void removeHeader(byte[] name) Removes the header with the given name- Parameters:
name
- the header name
-
clearHeaders
void clearHeaders()Clears the headers datastructure -
getWCCRequest
IRequest getWCCRequest()Get the webcontainer channel request object for this response- Returns:
- IWCCRequest the associated request for this response
-
setFlushMode
void setFlushMode(boolean flushToWire) Sets the flush mode. When set to true, the subsequent flush calls *must* write the contents to the wire. Otherwise, the contents written can be buffered by the underlying layer.- Parameters:
flushToWire
-
-
setIsClosing
void setIsClosing(boolean isClosing) -
getFlushMode
boolean getFlushMode()Gets the flush mode.- Returns:
- flushToWire
-
flushBufferedContent
void flushBufferedContent()Flushes the contents to wire -
setReason
Sets the reason in the response.- Parameters:
reason
-
-
setReason
void setReason(byte[] reason) Sets the reason in the response.- Parameters:
reason
-
-
addCookie
void addCookie(jakarta.servlet.http.Cookie cookie) Add a cookie to the response.- Parameters:
cookie
-
-
getCookies
jakarta.servlet.http.Cookie[] getCookies()Get all the cookies for the response- Returns:
- Cookie[] containing all the Cookies.
-
prepareHeadersForWrite
void prepareHeadersForWrite()Prepare to write the headers -
writeHeaders
void writeHeaders()Write the headers -
setHeader
- Parameters:
name
-s
-
-
setHeader
void setHeader(byte[] name, byte[] bs) - Parameters:
name
-bs
-
-
setContentType
Set the content type for the response- Parameters:
value
-
-
setContentType
void setContentType(byte[] value) Set the content type for the response- Parameters:
value
-
-
setContentLanguage
Set the content language for the response- Parameters:
value
-
-
setContentLength
void setContentLength(int length) Set the content length for the response- Parameters:
length
-
-
setContentLanguage
void setContentLanguage(byte[] value) Set the content language for the response- Parameters:
value
-
-
setAllocateDirect
void setAllocateDirect(boolean allocateDirect) Set whether to allocate direct or indirect byte buffers- Parameters:
allocateDirect
-
-
isAllocateDirect
boolean isAllocateDirect()Get whether to allocate direct or indirect byte buffers -
setLastBuffer
void setLastBuffer(boolean writeLastBuffer) Set the last buffer mode- Parameters:
writeLastBuffer
-
-
releaseChannel
void releaseChannel() -
removeCookie
-
resetBuffer
void resetBuffer() -
getBufferSize
int getBufferSize() -
setBufferSize
void setBufferSize(int bufferSize) -
flushBuffer
- Throws:
IOException
-