public class ResteasyHttpServletResponseWrapper extends ServletResponseWrapper implements 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| Constructor and Description |
|---|
ResteasyHttpServletResponseWrapper(HttpServletResponse response,
HttpServletResponse proxy) |
| Modifier and Type | Method and Description |
|---|---|
void |
addCookie(Cookie cookie)
Adds the specified cookie to the response.
|
void |
addDateHeader(String name,
long date)
Adds a response header with the given name and
date-value.
|
void |
addHeader(String name,
String value)
Adds a response header with the given name and value.
|
void |
addIntHeader(String name,
int value)
Adds a response header with the given name and
integer value.
|
boolean |
containsHeader(String name)
Returns a boolean indicating whether the named response header
has already been set.
|
String |
encodeRedirectUrl(String url)
Deprecated.
As of version 2.1, use
encodeRedirectURL(String url) instead
|
String |
encodeRedirectURL(String url)
Encodes the specified URL for use in the
sendRedirect method or, if encoding is not needed,
returns the URL unchanged. |
String |
encodeUrl(String url)
Deprecated.
As of version 2.1, use encodeURL(String url) instead
|
String |
encodeURL(String url)
Encodes the specified URL by including the session ID,
or, if encoding is not needed, returns the URL unchanged.
|
void |
flushBuffer()
The default behavior of this method is to call flushBuffer()
on the wrapped response object.
|
int |
getBufferSize()
The default behavior of this method is to return getBufferSize()
on the wrapped response object.
|
String |
getCharacterEncoding()
The default behavior of this method is to return getCharacterEncoding()
on the wrapped response object.
|
String |
getContentType()
The default behavior of this method is to return getContentType()
on the wrapped response object.
|
String |
getHeader(String name)
Gets the value of the response header with the given name.
|
Collection<String> |
getHeaderNames()
Gets the names of the headers of this response.
|
Collection<String> |
getHeaders(String name)
Gets the values of the response header with the given name.
|
HttpServletResponse |
getHttpServletResponse() |
Locale |
getLocale()
The default behavior of this method is to return getLocale()
on the wrapped response object.
|
ServletOutputStream |
getOutputStream()
The default behavior of this method is to return getOutputStream()
on the wrapped response object.
|
ServletResponse |
getResponse()
Return the wrapped ServletResponse object.
|
int |
getStatus()
Gets the current status code of this response.
|
PrintWriter |
getWriter()
The default behavior of this method is to return getWriter()
on the wrapped response object.
|
boolean |
isCommitted()
The default behavior of this method is to return isCommitted()
on the wrapped response object.
|
void |
reset()
The default behavior of this method is to call reset()
on the wrapped response object.
|
void |
resetBuffer()
The default behavior of this method is to call resetBuffer()
on the wrapped response object.
|
void |
sendError(int sc)
Sends an error response to the client using the specified status
code and clears the buffer.
|
void |
sendError(int sc,
String msg)
Sends an error response to the client using the specified
status and clears the buffer.
|
void |
sendRedirect(String location)
Sends a temporary redirect response to the client using the
specified redirect location URL and clears the buffer.
|
void |
setBufferSize(int size)
The default behavior of this method is to call setBufferSize(int size)
on the wrapped response object.
|
void |
setCharacterEncoding(String charset)
The default behavior of this method is to call setCharacterEncoding(String charset)
on the wrapped response object.
|
void |
setContentLength(int len)
The default behavior of this method is to call setContentLength(int len)
on the wrapped response object.
|
void |
setContentType(String type)
The default behavior of this method is to call setContentType(String type)
on the wrapped response object.
|
void |
setDateHeader(String name,
long date)
Sets a response header with the given name and
date-value.
|
void |
setHeader(String name,
String value)
Sets a response header with the given name and value.
|
void |
setIntHeader(String name,
int value)
Sets a response header with the given name and
integer value.
|
void |
setLocale(Locale loc)
The default behavior of this method is to call setLocale(Locale loc)
on the wrapped response object.
|
void |
setStatus(int sc)
Sets the status code for this response.
|
void |
setStatus(int sc,
String sm)
Deprecated.
As of version 2.1, due to ambiguous meaning of the
message parameter. To set a status code
use
setStatus(int), to send an error with a description
use sendError(int, String).
Sets the status code and message for this response. |
isWrapperFor, isWrapperFor, setContentLengthLong, setResponseclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsetContentLengthLongpublic ResteasyHttpServletResponseWrapper(HttpServletResponse response, HttpServletResponse proxy)
public HttpServletResponse getHttpServletResponse()
public ServletResponse getResponse()
ServletResponseWrappergetResponse in class ServletResponseWrapperpublic String getCharacterEncoding()
ServletResponseWrappergetCharacterEncoding in interface ServletResponsegetCharacterEncoding in class ServletResponseWrapperString specifying the name of
the character encoding, for example, UTF-8public String getContentType()
ServletResponseWrappergetContentType in interface ServletResponsegetContentType in class ServletResponseWrapperString specifying the content type,
for example, text/html; charset=UTF-8, or nullpublic ServletOutputStream getOutputStream() throws IOException
ServletResponseWrappergetOutputStream in interface ServletResponsegetOutputStream in class ServletResponseWrapperServletOutputStream for writing binary dataIOException - if an input or output exception occurredServletResponse.getWriter(),
ServletResponse.reset()public PrintWriter getWriter() throws IOException
ServletResponseWrappergetWriter in interface ServletResponsegetWriter in class ServletResponseWrapperPrintWriter object that
can return character data to the clientUnsupportedEncodingException - if the character encoding returned
by getCharacterEncoding cannot be usedIOException - if an input or output exception occurredServletResponse.getOutputStream(),
ServletResponse.setCharacterEncoding(java.lang.String),
ServletResponse.reset()public void setCharacterEncoding(String charset)
ServletResponseWrappersetCharacterEncoding in interface ServletResponsesetCharacterEncoding in class ServletResponseWrappercharset - a String specifying only the character set
defined by IANA Character Sets
(http://www.iana.org/assignments/character-sets)ServletResponse.setContentType(java.lang.String),
ServletResponse.setLocale(java.util.Locale)public void setContentLength(int len)
ServletResponseWrappersetContentLength in interface ServletResponsesetContentLength in class ServletResponseWrapperlen - an integer specifying the length of the
content being returned to the client; sets the Content-Length headerpublic void setContentType(String type)
ServletResponseWrappersetContentType in interface ServletResponsesetContentType in class ServletResponseWrappertype - a String specifying the MIME
type of the contentServletResponse.setLocale(java.util.Locale),
ServletResponse.setCharacterEncoding(java.lang.String),
ServletResponse.getOutputStream(),
ServletResponse.getWriter()public void setBufferSize(int size)
ServletResponseWrappersetBufferSize in interface ServletResponsesetBufferSize in class ServletResponseWrappersize - the preferred buffer sizeServletResponse.getBufferSize(),
ServletResponse.flushBuffer(),
ServletResponse.isCommitted(),
ServletResponse.reset()public int getBufferSize()
ServletResponseWrappergetBufferSize in interface ServletResponsegetBufferSize in class ServletResponseWrapperServletResponse.setBufferSize(int),
ServletResponse.flushBuffer(),
ServletResponse.isCommitted(),
ServletResponse.reset()public void flushBuffer()
throws IOException
ServletResponseWrapperflushBuffer in interface ServletResponseflushBuffer in class ServletResponseWrapperIOExceptionServletResponse.setBufferSize(int),
ServletResponse.getBufferSize(),
ServletResponse.isCommitted(),
ServletResponse.reset()public void resetBuffer()
ServletResponseWrapperresetBuffer in interface ServletResponseresetBuffer in class ServletResponseWrapperServletResponse.setBufferSize(int),
ServletResponse.getBufferSize(),
ServletResponse.isCommitted(),
ServletResponse.reset()public boolean isCommitted()
ServletResponseWrapperisCommitted in interface ServletResponseisCommitted in class ServletResponseWrapperServletResponse.setBufferSize(int),
ServletResponse.getBufferSize(),
ServletResponse.flushBuffer(),
ServletResponse.reset()public void reset()
ServletResponseWrapperreset in interface ServletResponsereset in class ServletResponseWrapperServletResponse.setBufferSize(int),
ServletResponse.getBufferSize(),
ServletResponse.flushBuffer(),
ServletResponse.isCommitted()public void setLocale(Locale loc)
ServletResponseWrappersetLocale in interface ServletResponsesetLocale in class ServletResponseWrapperloc - the locale of the responseServletResponse.getLocale(),
ServletResponse.setContentType(java.lang.String),
ServletResponse.setCharacterEncoding(java.lang.String)public Locale getLocale()
ServletResponseWrappergetLocale in interface ServletResponsegetLocale in class ServletResponseWrapperServletResponse.setLocale(java.util.Locale)public void addCookie(Cookie cookie)
HttpServletResponseaddCookie in interface HttpServletResponsecookie - the Cookie to return to the clientpublic boolean containsHeader(String name)
HttpServletResponsecontainsHeader in interface HttpServletResponsename - the header nametrue if the named response header
has already been set;
false otherwisepublic String encodeURL(String url)
HttpServletResponseFor robust session tracking, all URLs emitted by a servlet should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.
If the URL is relative, it is always relative to the current HttpServletRequest.
encodeURL in interface HttpServletResponseurl - the url to be encoded.public String encodeRedirectURL(String url)
HttpServletResponsesendRedirect method or, if encoding is not needed,
returns the URL unchanged. The implementation of this method
includes the logic to determine whether the session ID
needs to be encoded in the URL. For example, if the browser supports
cookies, or session tracking is turned off, URL encoding is
unnecessary. Because the rules for making this determination can
differ from those used to decide whether to
encode a normal link, this method is separated from the
encodeURL method.
All URLs sent to the HttpServletResponse.sendRedirect
method should be run through this method. Otherwise, URL
rewriting cannot be used with browsers which do not support
cookies.
If the URL is relative, it is always relative to the current HttpServletRequest.
encodeRedirectURL in interface HttpServletResponseurl - the url to be encoded.HttpServletResponse.sendRedirect(java.lang.String),
HttpServletResponse.encodeUrl(java.lang.String)public String encodeUrl(String url)
encodeUrl in interface HttpServletResponseurl - the url to be encoded.public String encodeRedirectUrl(String url)
encodeRedirectUrl in interface HttpServletResponseurl - the url to be encoded.public void sendError(int sc,
String msg)
throws IOException
HttpServletResponseIf the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.
sendError in interface HttpServletResponsesc - the error status codemsg - the descriptive messageIOException - If an input or output exception occurspublic void sendError(int sc)
throws IOException
HttpServletResponseIf the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.
sendError in interface HttpServletResponsesc - the error status codeIOException - If an input or output exception occurspublic void sendRedirect(String location) throws IOException
HttpServletResponseHttpServletResponse.SC_FOUND 302 (Found).
This method can accept relative URLs;the servlet container must convert
the relative URL to an absolute URL
before sending the response to the client. If the location is relative
without a leading '/' the container interprets it as relative to
the current request URI. If the location is relative with a leading
'/' the container interprets it as relative to the servlet container root.
If the location is relative with two leading '/' the container interprets
it as a network-path reference (see
RFC 3986: Uniform Resource Identifier (URI): Generic Syntax, section 4.2
"Relative Reference").
If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.
sendRedirect in interface HttpServletResponselocation - the redirect location URLIOException - If an input or output exception occurspublic void setDateHeader(String name, long date)
HttpServletResponsecontainsHeader method can be used to test for the
presence of a header before setting its value.setDateHeader in interface HttpServletResponsename - the name of the header to setdate - the assigned date valueHttpServletResponse.containsHeader(java.lang.String),
HttpServletResponse.addDateHeader(java.lang.String, long)public void addDateHeader(String name, long date)
HttpServletResponseaddDateHeader in interface HttpServletResponsename - the name of the header to setdate - the additional date valueHttpServletResponse.setDateHeader(java.lang.String, long)public void setHeader(String name, String value)
HttpServletResponsecontainsHeader method can be
used to test for the presence of a header before setting its
value.setHeader in interface HttpServletResponsename - the name of the headervalue - the header value If it contains octet string,
it should be encoded according to RFC 2047
(http://www.ietf.org/rfc/rfc2047.txt)HttpServletResponse.containsHeader(java.lang.String),
HttpServletResponse.addHeader(java.lang.String, java.lang.String)public void addHeader(String name, String value)
HttpServletResponseaddHeader in interface HttpServletResponsename - the name of the headervalue - the additional header value If it contains
octet string, it should be encoded
according to RFC 2047
(http://www.ietf.org/rfc/rfc2047.txt)HttpServletResponse.setHeader(java.lang.String, java.lang.String)public void setIntHeader(String name, int value)
HttpServletResponsecontainsHeader
method can be used to test for the presence of a header before
setting its value.setIntHeader in interface HttpServletResponsename - the name of the headervalue - the assigned integer valueHttpServletResponse.containsHeader(java.lang.String),
HttpServletResponse.addIntHeader(java.lang.String, int)public void addIntHeader(String name, int value)
HttpServletResponseaddIntHeader in interface HttpServletResponsename - the name of the headervalue - the assigned integer valueHttpServletResponse.setIntHeader(java.lang.String, int)public void setStatus(int sc)
HttpServletResponseThis method is used to set the return status code when there is no error (for example, for the SC_OK or SC_MOVED_TEMPORARILY status codes).
If this method is used to set an error code, then the container's
error page mechanism will not be triggered. If there is an error and
the caller wishes to invoke an error page defined in the web
application, then HttpServletResponse.sendError(int, java.lang.String) must be used instead.
This method preserves any cookies and other response headers.
Valid status codes are those in the 2XX, 3XX, 4XX, and 5XX ranges. Other status codes are treated as container specific.
setStatus in interface HttpServletResponsesc - the status codeHttpServletResponse.sendError(int, java.lang.String)public void setStatus(int sc,
String sm)
setStatus(int), to send an error with a description
use sendError(int, String).
Sets the status code and message for this response.setStatus in interface HttpServletResponsesc - the status codesm - the status messagepublic int getStatus()
HttpServletResponsegetStatus in interface HttpServletResponsepublic String getHeader(String name)
HttpServletResponseIf a response header with the given name exists and contains multiple values, the value that was added first will be returned.
This method considers only response headers set or added via
HttpServletResponse.setHeader(java.lang.String, java.lang.String), HttpServletResponse.addHeader(java.lang.String, java.lang.String), HttpServletResponse.setDateHeader(java.lang.String, long),
HttpServletResponse.addDateHeader(java.lang.String, long), HttpServletResponse.setIntHeader(java.lang.String, int), or
HttpServletResponse.addIntHeader(java.lang.String, int), respectively.
getHeader in interface HttpServletResponsename - the name of the response header whose value to returnpublic Collection<String> getHeaders(String name)
HttpServletResponseThis method considers only response headers set or added via
HttpServletResponse.setHeader(java.lang.String, java.lang.String), HttpServletResponse.addHeader(java.lang.String, java.lang.String), HttpServletResponse.setDateHeader(java.lang.String, long),
HttpServletResponse.addDateHeader(java.lang.String, long), HttpServletResponse.setIntHeader(java.lang.String, int), or
HttpServletResponse.addIntHeader(java.lang.String, int), respectively.
Any changes to the returned Collection must not
affect this HttpServletResponse.
getHeaders in interface HttpServletResponsename - the name of the response header whose values to returnCollection of the values
of the response header with the given namepublic Collection<String> getHeaderNames()
HttpServletResponseThis method considers only response headers set or added via
HttpServletResponse.setHeader(java.lang.String, java.lang.String), HttpServletResponse.addHeader(java.lang.String, java.lang.String), HttpServletResponse.setDateHeader(java.lang.String, long),
HttpServletResponse.addDateHeader(java.lang.String, long), HttpServletResponse.setIntHeader(java.lang.String, int), or
HttpServletResponse.addIntHeader(java.lang.String, int), respectively.
Any changes to the returned Collection must not
affect this HttpServletResponse.
getHeaderNames in interface HttpServletResponseCollection of the names
of the headers of this responseCopyright © 2018 JBoss by Red Hat. All rights reserved.