Top Methods
org.eclipse.jetty.ee10.websocket.server

public Interface JettyServerUpgradeResponse

extends UpgradeResponse
Known Direct Implementers
org.eclipse.jetty.ee10.websocket.server.internal.DelegatedServerUpgradeResponse
Imports
java.io.IOException, java.util.List, org.eclipse.jetty.websocket.api.ExtensionConfig, .UpgradeRequest, .UpgradeResponse

Method Summary

Modifier and TypeMethod and Description
public void
addHeader(String
the header name
name
,
String
the header value
value
)

Add a header value to the response.

public boolean

Returns:

a boolean indicating if the response has been committed.
isCommitted
()

Returns a boolean indicating if the response has been committed.

public void
sendError(int
the error status code
statusCode
,
String
the descriptive message
message
)

Sends an error response to the client using the specified status.

public void
sendForbidden(String
the short 1 line detail message about the forbidden response
message
)

Issue a forbidden upgrade response.

public void
setAcceptedSubProtocol(String
the protocol to list as accepted
protocol
)

Set the accepted WebSocket Protocol.

public void
setExtensions(List<ExtensionConfig>
the list of extensions to use.
extensions
)

Set the list of extensions that are approved for use with this websocket.

public void
setHeader(String
the header name
name
,
String
the header value
value
)

Set a header

Overrides previous value of header (if set)

public void
setHeader(String
the header name
name
,
List<String>
the header values
values
)

Set a header

Overrides previous value of header (if set)

public void
setStatusCode(int
the status code
statusCode
)

Set the HTTP Response status code

Inherited from org.eclipse.jetty.websocket.api.UpgradeResponse:
getAcceptedSubProtocolgetExtensionsgetHeadergetHeaderNamesgetHeadersgetHeadersgetStatusCode

Method Detail

addHeaderback to summary
public void addHeader(String name, String value)

Add a header value to the response.

Parameters
name:String

the header name

value:String

the header value

isCommittedback to summary
public 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:boolean

a boolean indicating if the response has been committed.

sendErrorback to summary
public void sendError(int statusCode, String message) throws IOException

Sends an error response to the client using the specified status.

Parameters
statusCode:int

the error status code

message:String

the descriptive message

Exceptions
IOException:
If an input or output exception occurs
IllegalStateException:
If the response was committed
sendForbiddenback to summary
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.

Parameters
message:String

the short 1 line detail message about the forbidden response

Exceptions
IOException:
if unable to send the forbidden
setAcceptedSubProtocolback to summary
public void setAcceptedSubProtocol(String protocol)

Set the accepted WebSocket Protocol.

Parameters
protocol:String

the protocol to list as accepted

setExtensionsback to summary
public void setExtensions(List<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.
Parameters
extensions:List<ExtensionConfig>

the list of extensions to use.

setHeaderback to summary
public void setHeader(String name, String value)

Set a header

Overrides previous value of header (if set)

Parameters
name:String

the header name

value:String

the header value

setHeaderback to summary
public void setHeader(String name, List<String> values)

Set a header

Overrides previous value of header (if set)

Parameters
name:String

the header name

values:List<String>

the header values

setStatusCodeback to summary
public void setStatusCode(int statusCode)

Set the HTTP Response status code

Parameters
statusCode:int

the status code