public class WebSocketUpgradeRequest extends HttpRequest implements Response.CompleteListener, HttpConnectionUpgrader
Request.BeginListener, Request.CommitListener, Request.ContentListener, Request.FailureListener, Request.HeadersListener, Request.Listener, Request.QueuedListener, Request.RequestListener, Request.SuccessListener
Modifier | Constructor and Description |
---|---|
protected |
WebSocketUpgradeRequest(WebSocketClient wsClient,
HttpClient httpClient,
ClientUpgradeRequest request)
Exists for internal use of HttpClient by WebSocketClient.
|
|
WebSocketUpgradeRequest(WebSocketClient wsClient,
HttpClient httpClient,
URI wsURI,
Object localEndpoint)
Initiating a WebSocket Upgrade using HTTP/1.1
|
Modifier and Type | Method and Description |
---|---|
void |
onComplete(Result result)
Callback method invoked when the request and the response have been processed,
either successfully or not.
|
ContentResponse |
send()
Sends this request and returns the response.
|
void |
send(Response.CompleteListener listener)
Sends this request and asynchronously notifies the given listener for response events.
|
CompletableFuture<Session> |
sendAsync() |
void |
setUpgradeListener(UpgradeListener upgradeListener) |
void |
upgrade(HttpResponse response,
HttpConnectionOverHTTP oldConn) |
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, getTimeout, getURI, getVersion, header, header, idleTimeout, isFollowRedirects, listener, method, method, onComplete, onRequestBegin, onRequestCommit, onRequestContent, onRequestFailure, onRequestHeaders, onRequestQueued, onRequestSuccess, onResponseBegin, onResponseContent, onResponseContentAsync, onResponseFailure, onResponseHeader, onResponseHeaders, onResponseSuccess, param, path, pushListener, scheme, timeout, toString, version
protected WebSocketUpgradeRequest(WebSocketClient wsClient, HttpClient httpClient, ClientUpgradeRequest request)
Maintained for Backward compatibility and also for JSR356 WebSocket ClientContainer use.
httpClient
- the HttpClient that this request usesrequest
- the ClientUpgradeRequest (backward compat) to base this request frompublic WebSocketUpgradeRequest(WebSocketClient wsClient, HttpClient httpClient, URI wsURI, Object localEndpoint)
httpClient
- 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 topublic void onComplete(Result result)
Response.CompleteListener
The result
parameter 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)
or
Response.FailureListener.onFailure(Response, Throwable)
, and only when request indicates that
it is completed.
onComplete
in interface Response.CompleteListener
result
- the result of the request / response exchangepublic ContentResponse send() throws InterruptedException, TimeoutException, ExecutionException
Request
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 own Response.Listener
or a utility
listener such as InputStreamResponseListener
.
The method returns when the complete event
is fired.
send
in interface Request
send
in class HttpRequest
ContentResponse
for this requestInterruptedException
- if send thread is interruptedTimeoutException
- if send times outExecutionException
- if execution failsResponse.CompleteListener.onComplete(Result)
public void send(Response.CompleteListener listener)
Request
Sends 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.CompleteListener
but 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.
send
in interface Request
send
in class HttpRequest
listener
- the listener that receives response eventspublic CompletableFuture<Session> sendAsync()
public void upgrade(HttpResponse response, HttpConnectionOverHTTP oldConn)
upgrade
in interface HttpConnectionUpgrader
public void setUpgradeListener(UpgradeListener upgradeListener)
Copyright © 1995–2017 Webtide. All rights reserved.