Class WebSocketUpgradeRequest

    • 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 uses
        httpClient - the HttpClient that this request uses
        request - 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 uses
        httpClient - the HttpClient that this request uses
        localEndpoint - the local endpoint (following Jetty WebSocket Client API rules) to use for incoming WebSocket events
        wsURI - the WebSocket URI to connect to
    • Method Detail

      • send

        public ContentResponse send()
                             throws java.lang.InterruptedException,
                                    java.util.concurrent.TimeoutException,
                                    java.util.concurrent.ExecutionException
        Description copied from interface: Request
        Sends 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 own Response.Listener or a utility listener such as InputStreamResponseListener.

        The method returns when the complete event is fired.

        Specified by:
        send in interface Request
        Overrides:
        send in class HttpRequest
        Returns:
        a ContentResponse for this request
        Throws:
        java.lang.InterruptedException - if send thread is interrupted
        java.util.concurrent.TimeoutException - if send times out
        java.util.concurrent.ExecutionException - if execution fails
        See Also:
        Response.CompleteListener.onComplete(Result)
      • send

        public void send​(Response.CompleteListener listener)
        Description copied from interface: 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.

        Specified by:
        send in interface Request
        Overrides:
        send in class HttpRequest
        Parameters:
        listener - the listener that receives response events
      • sendAsync

        public java.util.concurrent.CompletableFuture<Session> sendAsync()
      • setUpgradeListener

        public void setUpgradeListener​(UpgradeListener upgradeListener)