Class Response
- java.lang.Object
-
- org.glassfish.grizzly.http.server.Response
-
public class Response extends Object
Wrapper object for the Coyote response.- Version:
- $Revision: 1.2 $ $Date: 2006/11/02 20:01:44 $
- Author:
- Remy Maucherat, Craig R. McClanahan
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classResponse.SuspendedContextImplprotected classResponse.SuspendTimeout
-
Field Summary
Fields Modifier and Type Field Description protected booleanappCommittedThe application commit flag.protected org.glassfish.grizzly.filterchain.FilterChainContextctxGrizzlyFilterChaincontext, related to this HTTP request/responseprotected org.glassfish.grizzly.utils.DelayedExecutor.DelayQueue<Response.SuspendTimeout>delayQueueprotected booleanerrorThe error flag.protected SimpleDateFormatformatThe date format we will use for creating date headers.protected org.glassfish.grizzly.http.HttpContexthttpContextGrizzlyHttpContextassociated with the current Request/Response processing.protected static StringinfoDescriptive information about this Response implementation.protected ServerOutputBufferoutputBufferThe associated output buffer.protected org.glassfish.grizzly.http.util.CharChunkredirectURLCCRecyclable buffer to hold the redirect URL.protected RequestrequestThe request with which this response is associated.protected org.glassfish.grizzly.http.HttpResponsePacketresponseCoyote response.protected org.glassfish.grizzly.http.util.UEncoderurlEncoderURL encoder.protected booleanusingOutputStreamUsing output stream flag.protected booleanusingWriterUsing writer flag.
-
Constructor Summary
Constructors Modifier Constructor Description protectedResponse()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddCookie(org.glassfish.grizzly.http.Cookie cookie)Add the specified Cookie to those that will be included with this Response.voidaddDateHeader(String name, long value)Add the specified date header to the specified value.voidaddDateHeader(org.glassfish.grizzly.http.util.Header header, long value)Add the specified date header to the specified value.voidaddHeader(String name, String value)Add the specified header to the specified value.voidaddHeader(String name, org.glassfish.grizzly.http.util.HeaderValue value)Add the specified header to the specified value.voidaddHeader(org.glassfish.grizzly.http.util.Header header, String value)Add the specified header to the specified value.voidaddHeader(org.glassfish.grizzly.http.util.Header header, org.glassfish.grizzly.http.util.HeaderValue value)Add the specified header to the specified value.voidaddIntHeader(String name, int value)Add the specified integer header to the specified value.voidaddIntHeader(org.glassfish.grizzly.http.util.Header header, int value)Add the specified integer header to the specified value.protected voidaddSessionCookieInternal(org.glassfish.grizzly.http.Cookie cookie)Special method for adding a session cookie as we should be overriding any previousvoidcancel()Deprecated.pls.booleancontainsHeader(String name)Has the specified header been set already in this response?booleancontainsHeader(org.glassfish.grizzly.http.util.Header header)Has the specified header been set already in this response?org.glassfish.grizzly.http.io.NIOOutputStreamcreateOutputStream()Create and return a ServletOutputStream to write the content associated with this Response.StringencodeRedirectURL(String url)Encode the session identifier associated with this response into the specified redirect URL, if necessary.StringencodeURL(String url)Encode the session identifier associated with this response into the specified URL, if necessary.static Stringfilter(String message)Filter the specified message string for characters that are sensitive in HTML.voidfinish()Perform whatever actions are required to flush and close the output stream or writer, in a single operation.voidflush()Flush the current buffered content to the network.intgetBufferSize()Return the actual buffer size used for this Response.StringgetCharacterEncoding()Return the character encoding used for this Response.intgetContentLength()Return the content length that was set or calculated for this Response.longgetContentLengthLong()Return the content length that was set or calculated for this Response.StringgetContentType()Return the content type that was set or calculated for this response, ornullif no content type was set.org.glassfish.grizzly.http.Cookie[]getCookies()Return an array of all cookies set for this response, or a zero-length array if no cookies have been set.StringgetDetailMessage()Gets detail error message.ErrorPageGeneratorgetErrorPageGenerator()StringgetHeader(String name)Return the value for the specified header, ornullif this header has not been set.String[]getHeaderNames()Return an array of all the header names set for this response, or a zero-length array if no headers have been set.String[]getHeaderValues(String name)Return an array of all the header values associated with the specified header name, or an zero-length array if there are no such header values.StringgetInfo()Return descriptive information about this Response implementation and the corresponding version number, in the format<description>/<version>.LocalegetLocale()Return the Locale assigned to this response.StringgetMessage()Return the error message that was set withsendError()for this Response.org.glassfish.grizzly.http.io.NIOOutputStreamgetNIOOutputStream()Return theNIOOutputStreamassociated with thisResponse.org.glassfish.grizzly.http.io.NIOWritergetNIOWriter()Return theNIOWriterassociated with thisResponse.org.glassfish.grizzly.http.io.OutputBuffergetOutputBuffer()OutputStreamgetOutputStream()Return theOutputStreamassociated with thisResponse.RequestgetRequest()Return the Request with which this Response is associated.org.glassfish.grizzly.http.HttpResponsePacketgetResponse()Get theHttpResponsePacket.intgetStatus()Return the HTTP status code associated with this Response.SuspendContextgetSuspendContext()Get the context of the suspended Response.Supplier<Map<String,String>>getTrailers()WritergetWriter()Return theNIOWriterassociated with thisResponse.voidinitialize(Request request, org.glassfish.grizzly.http.HttpResponsePacket response, org.glassfish.grizzly.filterchain.FilterChainContext ctx, org.glassfish.grizzly.utils.DelayedExecutor.DelayQueue<Response.SuspendTimeout> delayQueue, HttpServerFilter serverFilter)booleanisCacheEnabled()Is the file cache enabled?booleanisCommitted()Has the output of this response already been committed?protected booleanisEncodeable(String location)Return true if the specified URL should be encoded with a session identifier.booleanisError()Error flag accessor.booleanisSendFileEnabled()booleanisSuspended()Return true/tt> if thatsuspend()has been invoked and set to trueprotected voidrecycle()Release all object references, and initialize instance variables, in preparation for reuse of this object.protected voidremoveSessionCookies()Removes any Set-Cookie response headers whose value contains the string "JSESSIONID=" or "JSESSIONIDSSO="voidreset()Clears any data that exists in the buffer as well as the status code and headers.voidreset(int status, String message)Reset this response, and specify the values for the HTTP status code and corresponding message.voidresetBuffer()Reset the data buffer but not any status or header information.voidresetBuffer(boolean resetWriterStreamFlags)Reset the data buffer and the using Writer/Stream flags but not any status or header information.voidresume()Complete theResponseand finish/commit it.voidsendAcknowledgement()Send an acknowledgment of a request.voidsendError(int status)Send an error response with the specified status and a default message.voidsendError(int status, String message)Send an error response with the specified status and message.voidsendRedirect(String location)Send a temporary redirect to the specified redirect location URL.voidsetBufferSize(int size)Set the buffer size to be used for this Response.voidsetCharacterEncoding(String charset)voidsetContentLength(int length)Set the content length (in bytes) for this Response.voidsetContentLengthLong(long length)Set the content length (in bytes) for this Response.voidsetContentType(String type)Set the content type for this Response.voidsetContentType(org.glassfish.grizzly.http.util.ContentType type)Set the content type for this Response.voidsetDateHeader(String name, long value)Set the specified date header to the specified value.voidsetDateHeader(org.glassfish.grizzly.http.util.Header header, long value)Set the specified date header to the specified value.voidsetDetailMessage(String message)Sets detail error message.voidsetError()Set the error flag.voidsetErrorPageGenerator(ErrorPageGenerator errorPageGenerator)voidsetHeader(String name, String value)Set the specified header to the specified value.voidsetHeader(String name, org.glassfish.grizzly.http.util.HeaderValue value)Set the specified header to the specified value.voidsetHeader(org.glassfish.grizzly.http.util.Header header, String value)Set the specified header to the specified value.voidsetHeader(org.glassfish.grizzly.http.util.Header header, org.glassfish.grizzly.http.util.HeaderValue value)Set the specified header to the specified value.voidsetIntHeader(String name, int value)Set the specified integer header to the specified value.voidsetIntHeader(org.glassfish.grizzly.http.util.Header header, int value)Set the specified integer header to the specified value.voidsetLocale(Locale locale)Set the Locale that is appropriate for this response, including setting the appropriate character encoding.voidsetStatus(int status)Set the HTTP status to be returned with this response.voidsetStatus(int status, String message)Set the HTTP status and message to be returned with this response.voidsetStatus(org.glassfish.grizzly.http.util.HttpStatus status)Set the HTTP status and message to be returned with this response.voidsetTrailers(Supplier<Map<String,String>> trailerSupplier)Set the supplier of trailer headers.voidsuspend()Suspend theResponse.voidsuspend(long timeout, TimeUnit timeunit)Deprecated.timeout parameters don't make any sense without CompletionHandlervoidsuspend(long timeout, TimeUnit timeunit, org.glassfish.grizzly.CompletionHandler<Response> completionHandler)Suspend theResponse.voidsuspend(long timeout, TimeUnit timeunit, org.glassfish.grizzly.CompletionHandler<Response> completionHandler, TimeoutHandler timeoutHandler)Suspend theResponse.protected StringtoAbsolute(String location, boolean normalize)Convert (if necessary) and return the absolute URL that represents the resource referenced by this possibly relative URL.protected StringtoEncoded(String url, String sessionId)Return the specified URL with the specified session identifier suitably encoded.
-
-
-
Field Detail
-
format
protected SimpleDateFormat format
The date format we will use for creating date headers.
-
info
protected static final String info
Descriptive information about this Response implementation.- See Also:
- Constant Field Values
-
request
protected Request request
The request with which this response is associated.
-
response
protected org.glassfish.grizzly.http.HttpResponsePacket response
Coyote response.
-
ctx
protected org.glassfish.grizzly.filterchain.FilterChainContext ctx
GrizzlyFilterChaincontext, related to this HTTP request/response
-
httpContext
protected org.glassfish.grizzly.http.HttpContext httpContext
GrizzlyHttpContextassociated with the current Request/Response processing.
-
outputBuffer
protected final ServerOutputBuffer outputBuffer
The associated output buffer.
-
appCommitted
protected boolean appCommitted
The application commit flag.
-
error
protected boolean error
The error flag.
-
usingOutputStream
protected boolean usingOutputStream
Using output stream flag.
-
usingWriter
protected boolean usingWriter
Using writer flag.
-
urlEncoder
protected final org.glassfish.grizzly.http.util.UEncoder urlEncoder
URL encoder.
-
redirectURLCC
protected final org.glassfish.grizzly.http.util.CharChunk redirectURLCC
Recyclable buffer to hold the redirect URL.
-
delayQueue
protected org.glassfish.grizzly.utils.DelayedExecutor.DelayQueue<Response.SuspendTimeout> delayQueue
-
-
Method Detail
-
initialize
public void initialize(Request request, org.glassfish.grizzly.http.HttpResponsePacket response, org.glassfish.grizzly.filterchain.FilterChainContext ctx, org.glassfish.grizzly.utils.DelayedExecutor.DelayQueue<Response.SuspendTimeout> delayQueue, HttpServerFilter serverFilter)
-
getRequest
public Request getRequest()
Return the Request with which this Response is associated.
-
getResponse
public org.glassfish.grizzly.http.HttpResponsePacket getResponse()
Get theHttpResponsePacket.
-
recycle
protected void recycle()
Release all object references, and initialize instance variables, in preparation for reuse of this object.
-
setTrailers
public void setTrailers(Supplier<Map<String,String>> trailerSupplier)
Set the supplier of trailer headers. The supplier will be called within the scope of whatever thread/call causes the response content to be completed. Typically this will be any thread calling close() on the output stream or writer. The trailers that run afoul of the provisions of section 4.1.2 of RFC 7230 are ignored.- Parameters:
trailerSupplier- the supplier of trailer headers- Throws:
IllegalStateException- if it is invoked after the response has has been committed, or trailers cannot be supported given the current protocol and/or configuration (chunked transfer encoding disabled in HTTP/1.1 as an example).- Since:
- 2.4.0
-
getTrailers
public Supplier<Map<String,String>> getTrailers()
- Returns:
- the trailers supplier, if any.
- Since:
- 2.4.0
-
encodeURL
public String encodeURL(String url)
Encode the session identifier associated with this response into the specified URL, if necessary.- Parameters:
url- URL to be encoded
-
encodeRedirectURL
public String encodeRedirectURL(String url)
Encode the session identifier associated with this response into the specified redirect URL, if necessary.- Parameters:
url- URL to be encoded
-
isEncodeable
protected boolean isEncodeable(String location)
Return true if the specified URL should be encoded with a session identifier. This will be true if all of the following conditions are met:- The request we are responding to asked for a valid session
- The requested session ID was not received via a cookie
- The specified URL points back to somewhere within the web application that is responding to this request
- Parameters:
location- Absolute URL to be validated
-
getInfo
public String getInfo()
Return descriptive information about this Response implementation and the corresponding version number, in the format<description>/<version>.
-
setError
public void setError()
Set the error flag.
-
isError
public boolean isError()
Error flag accessor.
-
getErrorPageGenerator
public ErrorPageGenerator getErrorPageGenerator()
- Returns:
- the
ErrorPageGeneratorto be used bysendError(int)orsendError(int, java.lang.String).
-
setErrorPageGenerator
public void setErrorPageGenerator(ErrorPageGenerator errorPageGenerator)
- Parameters:
errorPageGenerator- the customErrorPageGenerator.
-
setDetailMessage
public void setDetailMessage(String message)
Sets detail error message.- Parameters:
message- detail error message
-
getDetailMessage
public String getDetailMessage()
Gets detail error message.- Returns:
- the detail error message
-
finish
public void finish()
Perform whatever actions are required to flush and close the output stream or writer, in a single operation.
-
getContentLength
public int getContentLength()
Return the content length that was set or calculated for this Response.
-
getContentLengthLong
public long getContentLengthLong()
Return the content length that was set or calculated for this Response.
-
getContentType
public String getContentType()
Return the content type that was set or calculated for this response, ornullif no content type was set.
-
getBufferSize
public int getBufferSize()
Return the actual buffer size used for this Response.
-
getCharacterEncoding
public String getCharacterEncoding()
Return the character encoding used for this Response.
-
setCharacterEncoding
public void setCharacterEncoding(String charset)
-
createOutputStream
public org.glassfish.grizzly.http.io.NIOOutputStream createOutputStream()
Create and return a ServletOutputStream to write the content associated with this Response.
-
getNIOOutputStream
public org.glassfish.grizzly.http.io.NIOOutputStream getNIOOutputStream()
Return the
NIOOutputStreamassociated with thisResponse. ThisNIOOutputStreamwill write content in a non-blocking manner.- Throws:
IllegalStateException- ifgetWriter()orgetNIOWriter()were already invoked.
-
getOutputStream
public OutputStream getOutputStream()
Return the
By default the returnedOutputStreamassociated with thisResponse.NIOOutputStreamwill work as blockingOutputStream, but it will be possible to callOutputSink.canWrite()orOutputSink.notifyCanWrite(org.glassfish.grizzly.WriteHandler)to avoid blocking.- Returns:
- the
NIOOutputStreamassociated with thisResponse. - Throws:
IllegalStateException- ifgetWriter()orgetNIOWriter()were already invoked.- Since:
- 2.1.2
-
getLocale
public Locale getLocale()
Return the Locale assigned to this response.
-
getWriter
public Writer getWriter()
Return the
By default the returnedNIOWriterassociated with thisResponse.NIOWriterwill work as blockingWriter, but it will be possible to callOutputSink.canWrite()orOutputSink.notifyCanWrite(org.glassfish.grizzly.WriteHandler)to avoid blocking.- Throws:
IllegalStateException- ifgetOutputStream()orgetNIOOutputStream()were already invoked.
-
getNIOWriter
public org.glassfish.grizzly.http.io.NIOWriter getNIOWriter()
Return the
NIOWriterassociated with thisResponse. TheNIOWriterwill write content in a non-blocking manner.- Returns:
- the
NIOWriterassociated with thisResponse. - Throws:
IllegalStateException- ifgetOutputStream()orgetNIOOutputStream()were already invoked.- Since:
- 2.1.2
-
isCommitted
public boolean isCommitted()
Has the output of this response already been committed?
-
flush
public void flush() throws IOExceptionFlush the current buffered content to the network.- Throws:
IOException- if an occur occurs flushing to the wire.
-
getOutputBuffer
public org.glassfish.grizzly.http.io.OutputBuffer getOutputBuffer()
- Returns:
- the
OutputBufferassociated with thisResponse.
-
reset
public void reset()
Clears any data that exists in the buffer as well as the status code and headers.- Throws:
IllegalStateException- if this response has already been committed
-
resetBuffer
public void resetBuffer()
Reset the data buffer but not any status or header information.- Throws:
IllegalStateException- if the response has already been committed
-
resetBuffer
public void resetBuffer(boolean resetWriterStreamFlags)
Reset the data buffer and the using Writer/Stream flags but not any status or header information.- Parameters:
resetWriterStreamFlags-trueif the internalusingWriter,usingOutputStream,isCharacterEncodingSetflags should also be reset- Throws:
IllegalStateException- if the response has already been committed
-
setBufferSize
public void setBufferSize(int size)
Set the buffer size to be used for this Response.- Parameters:
size- The new buffer size- Throws:
IllegalStateException- if this method is called after output has been committed for this response
-
setContentLengthLong
public void setContentLengthLong(long length)
Set the content length (in bytes) for this Response. If thelengthargument is negative - thenHttpPacketcontent-length value will be reset to -1 and Content-Length header (if present) will be removed.- Parameters:
length- The new content length
-
setContentLength
public void setContentLength(int length)
Set the content length (in bytes) for this Response. If thelengthargument is negative - thenHttpPacketcontent-length value will be reset to -1 and Content-Length header (if present) will be removed.- Parameters:
length- The new content length
-
setContentType
public void setContentType(String type)
Set the content type for this Response.- Parameters:
type- The new content type
-
setContentType
public void setContentType(org.glassfish.grizzly.http.util.ContentType type)
Set the content type for this Response.- Parameters:
type- The new content type
-
setLocale
public void setLocale(Locale locale)
Set the Locale that is appropriate for this response, including setting the appropriate character encoding.- Parameters:
locale- The new locale
-
getCookies
public org.glassfish.grizzly.http.Cookie[] getCookies()
Return an array of all cookies set for this response, or a zero-length array if no cookies have been set.
-
getHeader
public String getHeader(String name)
Return the value for the specified header, ornullif this header has not been set. If more than one value was added for this name, only the first is returned; use getHeaderValues() to retrieve all of them.- Parameters:
name- Header name to look up
-
getHeaderNames
public String[] getHeaderNames()
Return an array of all the header names set for this response, or a zero-length array if no headers have been set.
-
getHeaderValues
public String[] getHeaderValues(String name)
Return an array of all the header values associated with the specified header name, or an zero-length array if there are no such header values.- Parameters:
name- Header name to look up
-
getMessage
public String getMessage()
Return the error message that was set withsendError()for this Response.
-
getStatus
public int getStatus()
Return the HTTP status code associated with this Response.
-
reset
public void reset(int status, String message)Reset this response, and specify the values for the HTTP status code and corresponding message.- Throws:
IllegalStateException- if this response has already been committed
-
addCookie
public void addCookie(org.glassfish.grizzly.http.Cookie cookie)
Add the specified Cookie to those that will be included with this Response.- Parameters:
cookie- Cookie to be added
-
addSessionCookieInternal
protected void addSessionCookieInternal(org.glassfish.grizzly.http.Cookie cookie)
Special method for adding a session cookie as we should be overriding any previous
-
removeSessionCookies
protected void removeSessionCookies()
Removes any Set-Cookie response headers whose value contains the string "JSESSIONID=" or "JSESSIONIDSSO="
-
addDateHeader
public void addDateHeader(String name, long value)
Add the specified date header to the specified value.- Parameters:
name- Name of the header to setvalue- Date value to be set
-
addDateHeader
public void addDateHeader(org.glassfish.grizzly.http.util.Header header, long value)Add the specified date header to the specified value.- Parameters:
header- theHeaderto setvalue- Date value to be set- Since:
- 2.1.2
-
addHeader
public void addHeader(String name, String value)
Add the specified header to the specified value.- Parameters:
name- Name of the header to setvalue- Value to be set
-
addHeader
public void addHeader(String name, org.glassfish.grizzly.http.util.HeaderValue value)
Add the specified header to the specified value.- Parameters:
name- Name of the header to setvalue- Value to be set- Since:
- 2.3.8
-
addHeader
public void addHeader(org.glassfish.grizzly.http.util.Header header, String value)Add the specified header to the specified value.- Parameters:
header- theHeaderto setvalue- Value to be set- Since:
- 2.1.2
-
addHeader
public void addHeader(org.glassfish.grizzly.http.util.Header header, org.glassfish.grizzly.http.util.HeaderValue value)Add the specified header to the specified value.- Parameters:
header- theHeaderto setvalue- Value to be set- Since:
- 2.3.8
-
addIntHeader
public void addIntHeader(String name, int value)
Add the specified integer header to the specified value.- Parameters:
name- Name of the header to setvalue- Integer value to be set
-
addIntHeader
public void addIntHeader(org.glassfish.grizzly.http.util.Header header, int value)Add the specified integer header to the specified value.- Parameters:
header- theHeaderto setvalue- Integer value to be set- Since:
- 2.1.2
-
containsHeader
public boolean containsHeader(String name)
Has the specified header been set already in this response?- Parameters:
name- Name of the header to check
-
containsHeader
public boolean containsHeader(org.glassfish.grizzly.http.util.Header header)
Has the specified header been set already in this response?- Parameters:
header- theHeaderto check- Since:
- 2.1.2
-
sendAcknowledgement
public void sendAcknowledgement() throws IOExceptionSend an acknowledgment of a request. An acknowledgment in this case is simply an HTTP response status line, i.e.HTTP/1.1 [STATUS] [REASON-PHRASE].- Throws:
IOException- if an input/output error occurs
-
sendError
public void sendError(int status) throws IOExceptionSend an error response with the specified status and a default message.- Parameters:
status- HTTP status code to send- Throws:
IllegalStateException- if this response has already been committedIOException- if an input/output error occurs
-
sendError
public void sendError(int status, String message) throws IOExceptionSend an error response with the specified status and message.- Parameters:
status- HTTP status code to sendmessage- Corresponding message to send- Throws:
IllegalStateException- if this response has already been committedIOException- if an input/output error occurs
-
sendRedirect
public void sendRedirect(String location) throws IOException
Send a temporary redirect to the specified redirect location URL.- Parameters:
location- Location URL to redirect to- Throws:
IllegalStateException- if this response has already been committedIOException- if an input/output error occurs
-
setDateHeader
public void setDateHeader(String name, long value)
Set the specified date header to the specified value.- Parameters:
name- Name of the header to setvalue- Date value to be set
-
setDateHeader
public void setDateHeader(org.glassfish.grizzly.http.util.Header header, long value)Set the specified date header to the specified value.- Parameters:
header- theHeaderto setvalue- Date value to be set- Since:
- 2.1.2
-
setHeader
public void setHeader(String name, String value)
Set the specified header to the specified value.- Parameters:
name- Name of the header to setvalue- Value to be set
-
setHeader
public void setHeader(String name, org.glassfish.grizzly.http.util.HeaderValue value)
Set the specified header to the specified value.- Parameters:
name- Name of the header to setvalue- Value to be set- Since:
- 2.3.8
-
setHeader
public void setHeader(org.glassfish.grizzly.http.util.Header header, String value)Set the specified header to the specified value.- Parameters:
header- theHeaderto setvalue- Value to be set- Since:
- 2.1.2
-
setHeader
public void setHeader(org.glassfish.grizzly.http.util.Header header, org.glassfish.grizzly.http.util.HeaderValue value)Set the specified header to the specified value.- Parameters:
header- theHeaderto setvalue- Value to be set- Since:
- 2.3.8
-
setIntHeader
public void setIntHeader(String name, int value)
Set the specified integer header to the specified value.- Parameters:
name- Name of the header to setvalue- Integer value to be set
-
setIntHeader
public void setIntHeader(org.glassfish.grizzly.http.util.Header header, int value)Set the specified integer header to the specified value.- Parameters:
header- theHeaderto setvalue- Integer value to be set- Since:
- 2.1.2
-
setStatus
public void setStatus(int status)
Set the HTTP status to be returned with this response.- Parameters:
status- The new HTTP status
-
setStatus
public void setStatus(int status, String message)Set the HTTP status and message to be returned with this response.- Parameters:
status- The new HTTP statusmessage- The associated text message
-
setStatus
public void setStatus(org.glassfish.grizzly.http.util.HttpStatus status)
Set the HTTP status and message to be returned with this response.- Parameters:
status-HttpStatusto set
-
toAbsolute
protected String toAbsolute(String location, boolean normalize)
Convert (if necessary) and return the absolute URL that represents the resource referenced by this possibly relative URL. If this URL is already absolute, return it unchanged.- Parameters:
location- URL to be (possibly) converted and then returned- Throws:
IllegalArgumentException- if a MalformedURLException is thrown when converting the relative URL to an absolute one
-
filter
public static String filter(String message)
Filter the specified message string for characters that are sensitive in HTML. This avoids potential attacks caused by including JavaScript codes in the request URL that is often reported in error messages.- Parameters:
message- The message string to be filtered
-
toEncoded
protected String toEncoded(String url, String sessionId)
Return the specified URL with the specified session identifier suitably encoded.- Parameters:
url- URL to be encoded with the session idsessionId- Session id to be included in the encoded URL
-
isCacheEnabled
public boolean isCacheEnabled()
Is the file cache enabled?
-
getSuspendContext
public SuspendContext getSuspendContext()
Get the context of the suspended Response.- Returns:
- the context of the suspended Response.
-
isSuspended
public boolean isSuspended()
Return true/tt> if thatsuspend()has been invoked and set to true- Returns:
- true/tt> if that
suspend()has been invoked and set to true
-
suspend
public void suspend()
-
suspend
@Deprecated public void suspend(long timeout, TimeUnit timeunit)
Deprecated.timeout parameters don't make any sense without CompletionHandlerSuspend theResponse. Suspending aResponsewill tell the underlying container to avoid recycling objects associated with the current instance, and also to avoid committing response.- Parameters:
timeout- The maximum amount of time, aResponsecan be suspended. When the timeout expires (because nothing has been written or because theresume()orcancel()), theResponsewill be automatically resumed and committed. Usage of any methods of aResponsethat times out will throw anIllegalStateException.timeunit- timeout units
-
suspend
public void suspend(long timeout, TimeUnit timeunit, org.glassfish.grizzly.CompletionHandler<Response> completionHandler)Suspend theResponse. Suspending aResponsewill tell the underlying container to avoid recycling objects associated with the current instance, and also to avoid committing response. When theresume()is invoked, the container will make sureCompletionHandler.completed(Object)is invoked with the original attachment. When thecancel()is invoked, the container will make sureCompletionHandler.cancelled()is invoked with the original attachment. If the timeout expires, theCompletionHandler.cancelled()is invoked with the original attachment and theResponsecommitted.- Parameters:
timeout- The maximum amount of time theResponsecan be suspended. When the timeout expires (because nothing has been written or because theresume()orcancel()), theResponsewill be automatically resumed and committed. Usage of any methods of aResponsethat times out will throw anIllegalStateException.timeunit- timeout unitscompletionHandler- aCompletionHandler
-
suspend
public void suspend(long timeout, TimeUnit timeunit, org.glassfish.grizzly.CompletionHandler<Response> completionHandler, TimeoutHandler timeoutHandler)Suspend theResponse. Suspending aResponsewill tell the underlying container to avoid recycling objects associated with the current instance, and also to avoid committing response. When theresume()is invoked, the container will make sureCompletionHandler.completed(Object)is invoked with the original attachment. When thecancel()is invoked, the container will make sureCompletionHandler.cancelled()is invoked with the original attachment. If the timeout expires, theCompletionHandler.cancelled()is invoked with the original attachment and theResponsecommitted.- Parameters:
timeout- The maximum amount of time theResponsecan be suspended. When the timeout expires (because nothing has been written or because theresume()orcancel()), theResponsewill be automatically resumed and committed. Usage of any methods of aResponsethat times out will throw anIllegalStateException.timeunit- timeout unitscompletionHandler- aCompletionHandlertimeoutHandler-TimeoutHandlerto customize the suspended Response timeout logic.
-
resume
public void resume()
-
cancel
@Deprecated public void cancel()
Deprecated.pls. useresume()
-
isSendFileEnabled
public boolean isSendFileEnabled()
-
-