Class UpgradeResponseAdapter
- java.lang.Object
-
- org.eclipse.jetty.websocket.common.UpgradeResponseAdapter
-
- All Implemented Interfaces:
org.eclipse.jetty.websocket.api.UpgradeResponse
public class UpgradeResponseAdapter extends Object implements org.eclipse.jetty.websocket.api.UpgradeResponse
-
-
Field Summary
Fields Modifier and Type Field Description static StringSEC_WEBSOCKET_PROTOCOL
-
Constructor Summary
Constructors Constructor Description UpgradeResponseAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddHeader(String name, String value)StringgetAcceptedSubProtocol()Get the accepted WebSocket protocol.List<org.eclipse.jetty.websocket.api.extensions.ExtensionConfig>getExtensions()Get the list of extensions that should be used for the websocket.StringgetHeader(String name)Set<String>getHeaderNames()Map<String,List<String>>getHeaders()List<String>getHeaders(String name)intgetStatusCode()StringgetStatusReason()booleanisSuccess()voidsendForbidden(String message)Issue a forbidden upgrade response.voidsetAcceptedSubProtocol(String protocol)Set the accepted WebSocket Protocol.voidsetExtensions(List<org.eclipse.jetty.websocket.api.extensions.ExtensionConfig> extensions)Set the list of extensions that are approved for use with this websocket.voidsetHeader(String name, String value)voidsetStatusCode(int statusCode)voidsetStatusReason(String statusReason)voidsetSuccess(boolean success)
-
-
-
Field Detail
-
SEC_WEBSOCKET_PROTOCOL
public static final String SEC_WEBSOCKET_PROTOCOL
- See Also:
- Constant Field Values
-
-
Method Detail
-
addHeader
public void addHeader(String name, String value)
- Specified by:
addHeaderin interfaceorg.eclipse.jetty.websocket.api.UpgradeResponse
-
getAcceptedSubProtocol
public String getAcceptedSubProtocol()
Get the accepted WebSocket protocol.- Specified by:
getAcceptedSubProtocolin interfaceorg.eclipse.jetty.websocket.api.UpgradeResponse- Returns:
- the accepted WebSocket protocol.
-
getExtensions
public List<org.eclipse.jetty.websocket.api.extensions.ExtensionConfig> getExtensions()
Get the list of extensions that should be used for the websocket.- Specified by:
getExtensionsin interfaceorg.eclipse.jetty.websocket.api.UpgradeResponse- Returns:
- the list of negotiated extensions to use.
-
getHeader
public String getHeader(String name)
- Specified by:
getHeaderin interfaceorg.eclipse.jetty.websocket.api.UpgradeResponse
-
getHeaderNames
public Set<String> getHeaderNames()
- Specified by:
getHeaderNamesin interfaceorg.eclipse.jetty.websocket.api.UpgradeResponse
-
getHeaders
public Map<String,List<String>> getHeaders()
- Specified by:
getHeadersin interfaceorg.eclipse.jetty.websocket.api.UpgradeResponse
-
getHeaders
public List<String> getHeaders(String name)
- Specified by:
getHeadersin interfaceorg.eclipse.jetty.websocket.api.UpgradeResponse
-
getStatusCode
public int getStatusCode()
- Specified by:
getStatusCodein interfaceorg.eclipse.jetty.websocket.api.UpgradeResponse
-
getStatusReason
public String getStatusReason()
- Specified by:
getStatusReasonin interfaceorg.eclipse.jetty.websocket.api.UpgradeResponse
-
isSuccess
public boolean isSuccess()
- Specified by:
isSuccessin interfaceorg.eclipse.jetty.websocket.api.UpgradeResponse
-
sendForbidden
public void sendForbidden(String message) throws IOException
Issue a forbidden upgrade response.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.
- Specified by:
sendForbiddenin interfaceorg.eclipse.jetty.websocket.api.UpgradeResponse- Parameters:
message- the short 1 line detail message about the forbidden response- Throws:
IOException- if unable to send the forbidden
-
setAcceptedSubProtocol
public void setAcceptedSubProtocol(String protocol)
Set the accepted WebSocket Protocol.- Specified by:
setAcceptedSubProtocolin interfaceorg.eclipse.jetty.websocket.api.UpgradeResponse- Parameters:
protocol- the protocol to list as accepted
-
setExtensions
public void setExtensions(List<org.eclipse.jetty.websocket.api.extensions.ExtensionConfig> extensions)
Set the list of extensions that are approved for use with this websocket.Notes:
- Per the spec you cannot add extensions that have not been seen in the
UpgradeRequest, just remove entries you don't want to use - If this is unused, or a null is passed, then the list negotiation will follow default behavior and use the complete list of extensions that are available in this WebSocket server implementation.
- Specified by:
setExtensionsin interfaceorg.eclipse.jetty.websocket.api.UpgradeResponse- Parameters:
extensions- the list of extensions to use.
- Per the spec you cannot add extensions that have not been seen in the
-
setHeader
public void setHeader(String name, String value)
- Specified by:
setHeaderin interfaceorg.eclipse.jetty.websocket.api.UpgradeResponse
-
setStatusCode
public void setStatusCode(int statusCode)
- Specified by:
setStatusCodein interfaceorg.eclipse.jetty.websocket.api.UpgradeResponse
-
setStatusReason
public void setStatusReason(String statusReason)
- Specified by:
setStatusReasonin interfaceorg.eclipse.jetty.websocket.api.UpgradeResponse
-
setSuccess
public void setSuccess(boolean success)
- Specified by:
setSuccessin interfaceorg.eclipse.jetty.websocket.api.UpgradeResponse
-
-