Interface JettyServerUpgradeResponse
- All Superinterfaces:
UpgradeResponse
- All Known Implementing Classes:
DelegatedServerUpgradeResponse
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a header value to the response.boolean
Returns a boolean indicating if the response has been committed.void
Sends an error response to the client using the specified status.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
Set a headervoid
Set a headervoid
setStatusCode
(int statusCode) Set the HTTP Response status codeMethods inherited from interface org.eclipse.jetty.websocket.api.UpgradeResponse
getAcceptedSubProtocol, getExtensions, getHeader, getHeaderNames, getHeaders, getHeaders, getStatusCode
-
Method Details
-
addHeader
Add a header value to the response.- Parameters:
name
- the header namevalue
- the header value
-
setHeader
Set a headerOverrides previous value of header (if set)
- Parameters:
name
- the header namevalue
- the header value
-
setHeader
Set a headerOverrides previous value of header (if set)
- Parameters:
name
- the header namevalues
- the header values
-
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
-
sendError
Sends an error response to the client using the specified status.- Parameters:
statusCode
- the error status codemessage
- the descriptive message- Throws:
IOException
- If an input or output exception occursIllegalStateException
- If the response was committed
-
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
-
setStatusCode
void setStatusCode(int statusCode) Set the HTTP Response status code- Parameters:
statusCode
- the status code
-
isCommitted
boolean isCommitted()Returns a boolean indicating if the response has been committed. A committed response has already had its status code and headers written.- Returns:
- a boolean indicating if the response has been committed.
-