Class WebSocketUpgradeRequest
- java.lang.Object
-
- org.eclipse.jetty.client.HttpRequest
-
- org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest
-
- All Implemented Interfaces:
java.util.EventListener,Request,Response.CompleteListener,Response.ResponseListener,HttpConnectionUpgrader
public class WebSocketUpgradeRequest extends HttpRequest implements Response.CompleteListener, HttpConnectionUpgrader
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.client.api.Request
Request.BeginListener, Request.CommitListener, Request.ContentListener, Request.FailureListener, Request.HeadersListener, Request.Listener, Request.QueuedListener, Request.RequestListener, Request.SuccessListener
-
-
Constructor Summary
Constructors Modifier Constructor Description WebSocketUpgradeRequest(WebSocketClient wsClient, HttpClient httpClient, java.net.URI wsURI, java.lang.Object localEndpoint)Initiating a WebSocket Upgrade using HTTP/1.1protectedWebSocketUpgradeRequest(WebSocketClient wsClient, HttpClient httpClient, ClientUpgradeRequest request)Exists for internal use of HttpClient by WebSocketClient.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidonComplete(Result result)Callback method invoked when the request and the response have been processed, either successfully or not.ContentResponsesend()Sends this request and returns the response.voidsend(Response.CompleteListener listener)Sends this request and asynchronously notifies the given listener for response events.java.util.concurrent.CompletableFuture<Session>sendAsync()voidsetUpgradeListener(UpgradeListener upgradeListener)voidupgrade(HttpResponse response, HttpConnectionOverHTTP oldConn)-
Methods inherited from class org.eclipse.jetty.client.HttpRequest
abort, accept, agent, attribute, content, content, cookie, file, file, followRedirects, getAbortCause, getAgent, getAttributes, getContent, getConversation, getCookies, getHeaders, getHost, getIdleTimeout, getMethod, getParams, getPath, getPort, getPushListener, getQuery, getRequestListeners, getResponseListeners, getScheme, getTag, getTimeout, getTrailers, getURI, getVersion, header, header, host, idleTimeout, isFollowRedirects, listener, method, method, onComplete, onRequestBegin, onRequestCommit, onRequestContent, onRequestFailure, onRequestHeaders, onRequestQueued, onRequestSuccess, onResponseBegin, onResponseContent, onResponseContentAsync, onResponseContentDemanded, onResponseFailure, onResponseHeader, onResponseHeaders, onResponseSuccess, param, path, port, pushListener, scheme, tag, timeout, toString, trailers, version
-
-
-
-
Constructor Detail
-
WebSocketUpgradeRequest
protected WebSocketUpgradeRequest(WebSocketClient wsClient, HttpClient httpClient, ClientUpgradeRequest request)
Exists for internal use of HttpClient by WebSocketClient.Maintained for Backward compatibility and also for JSR356 WebSocket ClientContainer use.
- Parameters:
wsClient- the WebSocketClient that this request useshttpClient- the HttpClient that this request usesrequest- the ClientUpgradeRequest (backward compat) to base this request from
-
WebSocketUpgradeRequest
public WebSocketUpgradeRequest(WebSocketClient wsClient, HttpClient httpClient, java.net.URI wsURI, java.lang.Object localEndpoint)
Initiating a WebSocket Upgrade using HTTP/1.1- Parameters:
wsClient- the WebSocketClient that this request useshttpClient- the HttpClient that this request useslocalEndpoint- the local endpoint (following Jetty WebSocket Client API rules) to use for incoming WebSocket eventswsURI- the WebSocket URI to connect to
-
-
Method Detail
-
onComplete
public void onComplete(Result result)
Description copied from interface:Response.CompleteListenerCallback method invoked when the request and the response have been processed, either successfully or not.The
resultparameter contains the request, the response, and eventual failures.Requests may complete after response, for example in case of big uploads that are discarded or read asynchronously by the server. This method is always invoked after
Response.SuccessListener.onSuccess(Response)orResponse.FailureListener.onFailure(Response, Throwable), and only when request indicates that it is completed.- Specified by:
onCompletein interfaceResponse.CompleteListener- Parameters:
result- the result of the request / response exchange
-
send
public ContentResponse send() throws java.lang.InterruptedException, java.util.concurrent.TimeoutException, java.util.concurrent.ExecutionException
Description copied from interface:RequestSends this request and returns the response.This method should be used when a simple blocking semantic is needed, and when it is known that the response content can be buffered without exceeding memory constraints.
For example, this method is not appropriate to download big files from a server; consider using
Request.send(Response.CompleteListener)instead, passing your ownResponse.Listeneror a utility listener such asInputStreamResponseListener.The method returns when the
complete eventis fired.- Specified by:
sendin interfaceRequest- Overrides:
sendin classHttpRequest- Returns:
- a
ContentResponsefor this request - Throws:
java.lang.InterruptedException- if send thread is interruptedjava.util.concurrent.TimeoutException- if send times outjava.util.concurrent.ExecutionException- if execution fails- See Also:
Response.CompleteListener.onComplete(Result)
-
send
public void send(Response.CompleteListener listener)
Description copied from interface:RequestSends this request and asynchronously notifies the given listener for response events.
This method should be used when the application needs to be notified of the various response events as they happen, or when the application needs to efficiently manage the response content.
The listener passed to this method may implement not only
Response.CompleteListenerbut also other response listener interfaces, and all the events implemented will be notified. This allows application code to write a single listener class to handle all relevant events.- Specified by:
sendin interfaceRequest- Overrides:
sendin classHttpRequest- Parameters:
listener- the listener that receives response events
-
sendAsync
public java.util.concurrent.CompletableFuture<Session> sendAsync()
-
upgrade
public void upgrade(HttpResponse response, HttpConnectionOverHTTP oldConn)
- Specified by:
upgradein interfaceHttpConnectionUpgrader
-
setUpgradeListener
public void setUpgradeListener(UpgradeListener upgradeListener)
-
-