Interface UpgradeResponse
- All Known Implementing Classes:
ClientUpgradeResponse, ServletUpgradeResponse, ServletWebSocketResponse, UpgradeResponseAdapter
public interface UpgradeResponse
The HTTP Upgrade to WebSocket Response
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a header value to the response.Get the accepted WebSocket protocol.Get the list of extensions that should be used for the websocket.Get a header valueGet the header namesGet the headers mapgetHeaders(String name) Get the multi-value header valueintGet the HTTP Response Status CodeGet the HTTP Response Status ReasonbooleanDeprecated.this has no replacement, will be removed in Jetty 10voidsendForbidden(String message) Issue a forbidden upgrade response.voidsetAcceptedSubProtocol(String protocol) Set the accepted WebSocket Protocol.voidsetExtensions(List<ExtensionConfig> extensions) Set the list of extensions that are approved for use with this websocket.voidSet a headervoidsetStatusCode(int statusCode) Set the HTTP Response status codevoidsetStatusReason(String statusReason) Set the HTTP Response status reason phrasevoidsetSuccess(boolean success) Deprecated.this has no replacement, will be removed in Jetty 10
-
Method Details
-
addHeader
-
getAcceptedSubProtocol
String getAcceptedSubProtocol()Get the accepted WebSocket protocol.- Returns:
- the accepted WebSocket protocol.
-
getExtensions
List<ExtensionConfig> getExtensions()Get the list of extensions that should be used for the websocket.- Returns:
- the list of negotiated extensions to use.
-
getHeader
-
getHeaderNames
-
getHeaders
-
getHeaders
-
getStatusCode
int getStatusCode()Get the HTTP Response Status Code- Returns:
- the status code
-
getStatusReason
String getStatusReason()Get the HTTP Response Status Reason- Returns:
- the HTTP Response status reason
-
isSuccess
Deprecated.this has no replacement, will be removed in Jetty 10Test if upgrade response is successful.Merely notes if the response was sent as a WebSocket Upgrade, or was failed (resulting in no upgrade handshake)
- Returns:
- true if upgrade response was generated, false if no upgrade response was generated
-
sendForbidden
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.
- Parameters:
message- the short 1 line detail message about the forbidden response- Throws:
IOException- if unable to send the forbidden
-
setAcceptedSubProtocol
Set the accepted WebSocket Protocol.- Parameters:
protocol- the protocol to list as accepted
-
setExtensions
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.
- Parameters:
extensions- the list of extensions to use.
- Per the spec you cannot add extensions that have not been seen in the
-
setHeader
-
setStatusCode
void setStatusCode(int statusCode) Set the HTTP Response status code- Parameters:
statusCode- the status code
-
setStatusReason
Set the HTTP Response status reason phraseNote, not all implementation of UpgradeResponse can support this feature
- Parameters:
statusReason- the status reason phrase
-
setSuccess
Deprecated.this has no replacement, will be removed in Jetty 10Set the success of the upgrade response.- Parameters:
success- true to indicate a response to the upgrade handshake was sent, false to indicate no upgrade response was sent
-