public class UpgradeResponseAdapter extends Object implements UpgradeResponse
| Modifier and Type | Field and Description |
|---|---|
static String |
SEC_WEBSOCKET_PROTOCOL |
| Constructor and Description |
|---|
UpgradeResponseAdapter() |
| Modifier and Type | Method and Description |
|---|---|
void |
addHeader(String name,
String value)
Add a header value to the response.
|
String |
getAcceptedSubProtocol()
Get the accepted WebSocket protocol.
|
List<ExtensionConfig> |
getExtensions()
Get the list of extensions that should be used for the websocket.
|
String |
getHeader(String name)
Get a header value
|
Set<String> |
getHeaderNames()
Get the header names
|
Map<String,List<String>> |
getHeaders()
Get the headers map
|
List<String> |
getHeaders(String name)
Get the multi-value header value
|
int |
getStatusCode()
Get the HTTP Response Status Code
|
String |
getStatusReason()
Get the HTTP Response Status Reason
|
boolean |
isSuccess()
Test if upgrade response is successful.
|
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 |
setHeader(String name,
String value)
Set a header
|
void |
setStatusCode(int statusCode)
Set the HTTP Response status code
|
void |
setStatusReason(String statusReason)
Set the HTTP Response status reason phrase
|
void |
setSuccess(boolean success)
Set the success of the upgrade response.
|
public static final String SEC_WEBSOCKET_PROTOCOL
public void addHeader(String name, String value)
UpgradeResponseaddHeader in interface UpgradeResponsename - the header namevalue - the header valuepublic String getAcceptedSubProtocol()
getAcceptedSubProtocol in interface UpgradeResponsepublic List<ExtensionConfig> getExtensions()
getExtensions in interface UpgradeResponsepublic String getHeader(String name)
UpgradeResponsegetHeader in interface UpgradeResponsename - the header namepublic Set<String> getHeaderNames()
UpgradeResponsegetHeaderNames in interface UpgradeResponsepublic Map<String,List<String>> getHeaders()
UpgradeResponsegetHeaders in interface UpgradeResponsepublic List<String> getHeaders(String name)
UpgradeResponsegetHeaders in interface UpgradeResponsename - the header namepublic int getStatusCode()
UpgradeResponsegetStatusCode in interface UpgradeResponsepublic String getStatusReason()
UpgradeResponsegetStatusReason in interface UpgradeResponsepublic boolean isSuccess()
UpgradeResponseMerely notes if the response was sent as a WebSocket Upgrade, or was failed (resulting in no upgrade handshake)
isSuccess in interface UpgradeResponsepublic void sendForbidden(String message) throws IOException
This 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 responseIOException - if unable to send the forbiddenpublic void setAcceptedSubProtocol(String protocol)
setAcceptedSubProtocol in interface UpgradeResponseprotocol - the protocol to list as acceptedpublic void setExtensions(List<ExtensionConfig> extensions)
Notes:
UpgradeRequest, just remove entries you don't want to usesetExtensions in interface UpgradeResponseextensions - the list of extensions to use.public void setHeader(String name, String value)
UpgradeResponseOverrides previous value of header (if set)
setHeader in interface UpgradeResponsename - the header namevalue - the header valuepublic void setStatusCode(int statusCode)
UpgradeResponsesetStatusCode in interface UpgradeResponsestatusCode - the status codepublic void setStatusReason(String statusReason)
UpgradeResponseNote, not all implementation of UpgradeResponse can support this feature
setStatusReason in interface UpgradeResponsestatusReason - the status reason phrasepublic void setSuccess(boolean success)
UpgradeResponsesetSuccess in interface UpgradeResponsesuccess - true to indicate a response to the upgrade handshake was sent, false to indicate no upgrade
response was sentCopyright © 2010 - 2020 Adobe. All Rights Reserved