Top Description Inners Fields Constructors Methods
org.glassfish.grizzly.http.server

public Class Response

extends Object
Class Inheritance
Static Imports
org.glassfish.grizzly.http.util.Constants.DEFAULT_HTTP_CHARACTER_ENCODING, .Constants.DEFAULT_HTTP_CHARSET

Wrapper object for the Coyote response.
Authors
Remy Maucherat, Craig R. McClanahan
Version
$Revision: 1.2 $ $Date: 2006/11/02 20:01:44 $

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
public class
pack-priv static enum
protected class

Field Summary

Modifier and TypeField and Description
protected boolean
appCommitted

The application commit flag.

private boolean
protected FilterChainContext
ctx

Grizzly org.glassfish.grizzly.filterchain.FilterChain context, related to this HTTP request/response

private static final Locale
DEFAULT_LOCALE

Default locale as mandated by the spec.

protected DelayedExecutor.DelayQueue<Response.SuspendTimeout>
protected boolean
error

The error flag.

private ErrorPageGenerator
protected DateTimeFormatter
format

The date format we will use for creating date headers.

private static final String
protected HttpContext
httpContext

Grizzly HttpContext associated with the current Request/Response processing.

protected static final String
info

Descriptive information about this Response implementation.

private static final Logger
protected final ServerOutputBuffer
outputBuffer

The associated output buffer.

private final NIOOutputStreamImpl
outputStream

The associated output stream.

protected final CharChunk
redirectURLCC

Recyclable buffer to hold the redirect URL.

protected Request
request

The request with which this response is associated.

protected HttpResponsePacket
response

Coyote response.

private boolean
private final Response.SuspendedContextImpl
pack-priv Response.SuspendState
private SuspendStatus
protected final UEncoder
urlEncoder

URL encoder.

protected boolean
usingOutputStream

Using output stream flag.

protected boolean
usingWriter

Using writer flag.

private final NIOWriterImpl
writer

The associated writer.

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public void
addCookie(final Cookie
Cookie to be added
cookie
)

Add the specified Cookie to those that will be included with this Response.

public void
addDateHeader(final String
Name of the header to set
name
,
final long
Date value to be set
value
)

Add the specified date header to the specified value.

public void
addDateHeader(final Header
the Header to set
header
,
final long
Date value to be set
value
)

Add the specified date header to the specified value.

public void
addHeader(final String
Name of the header to set
name
,
final String
Value to be set
value
)

Add the specified header to the specified value.

public void
addHeader(final String
Name of the header to set
name
,
final HeaderValue
Value to be set
value
)

Add the specified header to the specified value.

public void
addHeader(final Header
the Header to set
header
,
final String
Value to be set
value
)

Add the specified header to the specified value.

public void
addHeader(final Header
the Header to set
header
,
final HeaderValue
Value to be set
value
)

Add the specified header to the specified value.

public void
addIntHeader(final String
Name of the header to set
name
,
final int
Integer value to be set
value
)

Add the specified integer header to the specified value.

public void
addIntHeader(final Header
the Header to set
header
,
final int
Integer value to be set
value
)

Add the specified integer header to the specified value.

protected void
addSessionCookieInternal(final Cookie cookie)

Special method for adding a session cookie as we should be overriding any previous

public void
cancel()
Deprecated pls. use resume()

Cancel the Response and finish/commit it.

pack-priv final void
checkResponse()

Make sure the Response object has been set.

public boolean
containsHeader(final String
Name of the header to check
name
)

Has the specified header been set already in this response?

public boolean
containsHeader(final Header
the Header to check
header
)

Has the specified header been set already in this response?

pack-priv static DelayedExecutor.DelayQueue<Response.SuspendTimeout>
createDelayQueue(final DelayedExecutor delayedExecutor)

public NIOOutputStream
createOutputStream()

Create and return a ServletOutputStream to write the content associated with this Response.

private static boolean
doIsEncodeable(Request request, Session session, String location)

public String
encodeRedirectURL(String
URL to be encoded
url
)

Encode the session identifier associated with this response into the specified redirect URL, if necessary.

public String
encodeURL(String
URL to be encoded
url
)

Encode the session identifier associated with this response into the specified URL, if necessary.

public static String
filter(String
The message string to be filtered
message
)

Filter the specified message string for characters that are sensitive in HTML.

public void
finish()

Perform whatever actions are required to flush and close the output stream or writer, in a single operation.

public void
flush()

Flush the current buffered content to the network.

public int
getBufferSize()

Return the actual buffer size used for this Response.

public String
getCharacterEncoding()

Return the character encoding used for this Response.

public int
getContentLength()

Return the content length that was set or calculated for this Response.

public long
getContentLengthLong()

Return the content length that was set or calculated for this Response.

public String
getContentType()

Return the content type that was set or calculated for this response, or null if no content type was set.

public Cookie[]
getCookies()

Return an array of all cookies set for this response, or a zero-length array if no cookies have been set.

public String

Returns:

the detail error message
getDetailMessage
()

Gets detail error message.

public ErrorPageGenerator
public String
getHeader(String
Header name to look up
name
)

Return the value for the specified header, or null if this header has not been set.

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.

public String[]
getHeaderValues(final String
Header name to look up
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.

public String
getInfo()

Return descriptive information about this Response implementation and the corresponding version number, in the format <description>/<version>.

public Locale
getLocale()

Return the Locale assigned to this response.

public String
getMessage()

Return the error message that was set with sendError() for this Response.

public NIOOutputStream
getNIOOutputStream()

Return the NIOOutputStream associated with this Response.

public NIOWriter

Returns:

the NIOWriter associated with this Response.
getNIOWriter
()

Return the NIOWriter associated with this Response.

public OutputBuffer
getOutputBuffer()

Returns: the OutputBuffer associated with this Response.

public OutputStream

Returns:

the NIOOutputStream associated with this Response.
getOutputStream
()

Return the OutputStream associated with this Response.

public Request
getRequest()

Return the Request with which this Response is associated.

public HttpResponsePacket
public int
getStatus()

Return the HTTP status code associated with this Response.

public SuspendContext

Returns:

the context of the suspended Response.
getSuspendContext
()

Get the context of the suspended Response.

public Supplier<Map<String, String>>
getTrailers()

Returns: the trailers supplier, if any.

public Writer
getWriter()

Return the NIOWriter associated with this Response.

public void
initialize(final Request request, final HttpResponsePacket response, final FilterChainContext ctx, final DelayedExecutor.DelayQueue<Response.SuspendTimeout> delayQueue, final HttpServerFilter serverFilter)

pack-priv SuspendStatus
public boolean
isCacheEnabled()

Is the file cache enabled?

public boolean
isCommitted()

Has the output of this response already been committed?

protected boolean
isEncodeable(final String
Absolute URL to be validated
location
)

Return true if the specified URL should be encoded with a session identifier.

public boolean
isError()

Error flag accessor.

public boolean
public boolean

Returns:

true if that Response#suspend() has been invoked and set to true
isSuspended
()

Return true if that Response#suspend() has been invoked and set to true

protected void
recycle()

Release all object references, and initialize instance variables, in preparation for reuse of this object.

protected void
removeSessionCookies()

Removes any Set-Cookie response headers whose value contains the string "JSESSIONID=" or "JSESSIONIDSSO="

public void
reset()

Clears any data that exists in the buffer as well as the status code and headers.

public void
reset(final int status, final String message)

Reset this response, and specify the values for the HTTP status code and corresponding message.

public void
resetBuffer()

Reset the data buffer but not any status or header information.

public void
resetBuffer(final boolean
true if the internal usingWriter, usingOutputStream, isCharacterEncodingSet flags should also be reset
resetWriterStreamFlags
)

Reset the data buffer and the using Writer/Stream flags but not any status or header information.

public void
resume()

Complete the Response and finish/commit it.

public void
sendAcknowledgement()

Send an acknowledgment of a request.

public void
sendEarlyHints()

Send a 103 Early Hints interim response using the headers currently set on this response.

public void
sendError(int
HTTP status code to send
status
)

Send an error response with the specified status and a default message.

public void
sendError(final int
HTTP status code to send
status
,
final String
Corresponding message to send
message
)

Send an error response with the specified status and message.

public void
sendRedirect(String
Location URL to redirect to
location
)

Send a temporary redirect to the specified redirect location URL.

public void
sendRedirect(String
Location URL to redirect to
location
,
int sc, boolean clearBuffer)

Send a temporary redirect to the specified redirect location URL.

public void
setBufferSize(final int
The new buffer size
size
)

Set the buffer size to be used for this Response.

public void
public void
setContentLength(final int
The new content length
length
)

Set the content length (in bytes) for this Response.

public void
setContentLengthLong(final long
The new content length
length
)

Set the content length (in bytes) for this Response.

public void
setContentType(String
The new content type
type
)

Set the content type for this Response.

public void
setContentType(final ContentType
The new content type
type
)

Set the content type for this Response.

public void
setDateHeader(String
Name of the header to set
name
,
long
Date value to be set
value
)

Set the specified date header to the specified value.

public void
setDateHeader(final Header
the Header to set
header
,
long
Date value to be set
value
)

Set the specified date header to the specified value.

public void
setDetailMessage(String
detail error message
message
)

Sets detail error message.

public void
setError()

Set the error flag.

public void
public void
setHeader(final String
Name of the header to set
name
,
final String
Value to be set
value
)

Set the specified header to the specified value.

public void
setHeader(final String
Name of the header to set
name
,
final HeaderValue
Value to be set
value
)

Set the specified header to the specified value.

public void
setHeader(final Header
the Header to set
header
,
final String
Value to be set
value
)

Set the specified header to the specified value.

public void
setHeader(final Header
the Header to set
header
,
final HeaderValue
Value to be set
value
)

Set the specified header to the specified value.

public void
setIntHeader(String
Name of the header to set
name
,
int
Integer value to be set
value
)

Set the specified integer header to the specified value.

public void
setIntHeader(final Header
the Header to set
header
,
final int
Integer value to be set
value
)

Set the specified integer header to the specified value.

public void
setLocale(final Locale
The new locale
locale
)

Set the Locale that is appropriate for this response, including setting the appropriate character encoding.

public void
setStatus(int
The new HTTP status
status
)

Set the HTTP status to be returned with this response.

public void
setStatus(int
The new HTTP status
status
,
String
The associated text message
message
)

Set the HTTP status and message to be returned with this response.

public void
setStatus(HttpStatus
HttpStatus to set
status
)

Set the HTTP status and message to be returned with this response.

public void
setTrailers(Supplier<Map<String, String>>
the supplier of trailer headers
trailerSupplier
)

Set the supplier of trailer headers.

public void
suspend()

Suspend the Response.

public void
suspend(final long
The maximum amount of time, a Response can be suspended. When the timeout expires (because nothing has been written or because the Response#resume() or Response#cancel()), the Response will be automatically resumed and committed. Usage of any methods of a Response that times out will throw an IllegalStateException.
timeout
,
final TimeUnit
timeout units
timeunit
)
Deprecated timeout parameters don't make any sense without CompletionHandler

Suspend the Response.

public void
suspend(final long
The maximum amount of time the Response can be suspended. When the timeout expires (because nothing has been written or because the Response#resume() or Response#cancel()), the Response will be automatically resumed and committed. Usage of any methods of a Response that times out will throw an IllegalStateException.
timeout
,
final TimeUnit
timeout units
timeunit
,
final CompletionHandler<Response> completionHandler)

Suspend the Response.

public void
suspend(final long
The maximum amount of time the Response can be suspended. When the timeout expires (because nothing has been written or because the Response#resume() or Response#cancel()), the Response will be automatically resumed and committed. Usage of any methods of a Response that times out will throw an IllegalStateException.
timeout
,
final TimeUnit
timeout units
timeunit
,
final CompletionHandler<Response> completionHandler, final TimeoutHandler
TimeoutHandler to customize the suspended Response timeout logic.
timeoutHandler
)

Suspend the Response.

protected String
toAbsolute(final String
URL to be (possibly) converted and then returned
location
,
final boolean normalize)

Convert (if necessary) and return the absolute URL that represents the resource referenced by this possibly relative URL.

protected String
toEncoded(String
URL to be encoded with the session id
url
,
String
Session id to be included in the encoded URL
sessionId
)

Return the specified URL with the specified session identifier suitably encoded.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait