public class ServletWebSocketResponse extends HttpServletResponseWrapper implements UpgradeResponse
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 |
|---|
ServletWebSocketResponse(HttpServletResponse resp) |
| Modifier and Type | Method and Description |
|---|---|
void |
addHeader(String name,
String value) |
String |
getAcceptedSubProtocol()
Get the accepted WebSocket protocol.
|
List<ExtensionConfig> |
getExtensions()
Get the list of extensions that should be used for the websocket.
|
Set<String> |
getHeaderNamesSet() |
String |
getHeaderValue(String name) |
Iterator<String> |
getHeaderValues(String name) |
int |
getStatusCode() |
String |
getStatusReason() |
boolean |
isSuccess() |
void |
sendForbidden(String message)
Issue a forbidden upgrade response.
|
void |
setAcceptedSubProtocol(String protocol)
Set the accepted WebSocket Protocol.
|
void |
setExtensions(List<ExtensionConfig> extensions)
Set the list of extensions that are approved for use with this websocket.
|
void |
validateWebSocketHash(String expectedHash) |
addCookie, addDateHeader, addIntHeader, containsHeader, encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL, getHeader, getHeaderNames, getHeaders, getStatus, sendError, sendError, sendRedirect, setDateHeader, setHeader, setIntHeader, setStatus, setStatusflushBuffer, getBufferSize, getCharacterEncoding, getContentType, getLocale, getOutputStream, getResponse, getWriter, isCommitted, isWrapperFor, isWrapperFor, reset, resetBuffer, setBufferSize, setCharacterEncoding, setContentLength, setContentType, setLocale, setResponseclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsetHeaderflushBuffer, getBufferSize, getCharacterEncoding, getContentType, getLocale, getOutputStream, getWriter, isCommitted, reset, resetBuffer, setBufferSize, setCharacterEncoding, setContentLength, setContentType, setLocalepublic ServletWebSocketResponse(HttpServletResponse resp)
public void addHeader(String name, String value)
addHeader in interface HttpServletResponseaddHeader in interface UpgradeResponseaddHeader in class HttpServletResponseWrapperpublic String getAcceptedSubProtocol()
UpgradeResponsegetAcceptedSubProtocol in interface UpgradeResponsepublic List<ExtensionConfig> getExtensions()
UpgradeResponsegetExtensions in interface UpgradeResponsepublic Set<String> getHeaderNamesSet()
getHeaderNamesSet in interface UpgradeResponsepublic String getHeaderValue(String name)
getHeaderValue in interface UpgradeResponsepublic Iterator<String> getHeaderValues(String name)
getHeaderValues in interface UpgradeResponsepublic int getStatusCode()
getStatusCode in interface UpgradeResponsepublic String getStatusReason()
getStatusReason in interface UpgradeResponsepublic boolean isSuccess()
isSuccess in interface UpgradeResponsepublic void sendForbidden(String message) throws IOException
UpgradeResponseThis means that the websocket endpoint was valid, but the conditions to use a WebSocket resulted in a forbidden access.
Use this when the origin or authentication is invalid.
sendForbidden in interface UpgradeResponsemessage - the short 1 line detail message about the forbidden responseIOExceptionpublic void setAcceptedSubProtocol(String protocol)
UpgradeResponsesetAcceptedSubProtocol in interface UpgradeResponseprotocol - the protocol to list as acceptedpublic void setExtensions(List<ExtensionConfig> extensions)
UpgradeResponse
This is Advanced usage of the WebSocketCreator to allow for a custom set of negotiated extensions.
Notes:
UpgradeRequest, just remove entries you don't want to usesetExtensions in interface UpgradeResponseextensions - the list of extensions to use.public void validateWebSocketHash(String expectedHash) throws UpgradeException
validateWebSocketHash in interface UpgradeResponseUpgradeExceptionCopyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.