Package io.undertow.client

Examples of io.undertow.client.ClientResponse


        }
        addHttpHeaders(request, headers);
        connection.sendRequest(request, createRequestCallback(body, responses, latch));

        latch.await();
        final ClientResponse response = responses.iterator().next();
        HttpStatus status = HttpStatus.valueOf(response.getResponseCode());
        HttpHeaders responseHeaders = toHttpHeaders(response.getResponseHeaders());
        String responseBody = response.getAttachment(RESPONSE_BODY);
        return (responseBody != null ?
            new ResponseEntity<String>(responseBody, responseHeaders, status) :
            new ResponseEntity<String>(responseHeaders, status));
      }
      finally {
View Full Code Here


        result.setResponseListener(new ClientCallback<ClientExchange>() {
          @Override
          public void completed(final ClientExchange result) {

            ClientResponse response = result.getResponse();
            if (response.getResponseCode() != 200) {
              HttpStatus status = HttpStatus.valueOf(response.getResponseCode());
              IoUtils.safeClose(result.getConnection());
              onFailure(new HttpServerErrorException(status, "Unexpected XHR receive status"));
            }
            else {
              SockJsResponseListener listener = new SockJsResponseListener(result.getConnection(),
                  url, headers, sockJsSession, connectFuture);
              listener.setup(result.getResponseChannel());
            }
            if (logger.isTraceEnabled()) {
              logger.trace("XHR receive headers: " + toHttpHeaders(response.getResponseHeaders()));
            }
            try {
              result.getRequestChannel().shutdownWrites();
              if (!result.getRequestChannel().flush()) {
                result.getRequestChannel().getWriteSetter()
View Full Code Here

        }

        @Override
        public void completed(final ClientExchange result) {
            HttpServerExchange exchange = result.getAttachment(EXCHANGE);
            final ClientResponse response = result.getResponse();
            final HeaderMap inboundResponseHeaders = response.getResponseHeaders();
            final HeaderMap outboundResponseHeaders = exchange.getResponseHeaders();
            exchange.setResponseCode(response.getResponseCode());
            copyHeaders(outboundResponseHeaders, inboundResponseHeaders);
            if (exchange.isPersistent() && !result.getConnection().isOpen()) {
                //just because the client side is non-persistent it does not mean we want to close the connection to
                //the backend
                outboundResponseHeaders.put(Headers.CONNECTION, "keep-alive");
View Full Code Here

        }

        @Override
        public void completed(final ClientExchange result) {
            HttpServerExchange exchange = result.getAttachment(EXCHANGE);
            final ClientResponse response = result.getResponse();
            final HeaderMap inboundResponseHeaders = response.getResponseHeaders();
            final HeaderMap outboundResponseHeaders = exchange.getResponseHeaders();
            exchange.setResponseCode(response.getResponseCode());
            copyHeaders(outboundResponseHeaders, inboundResponseHeaders);
            if (exchange.isPersistent() && !result.getConnection().isOpen()) {
                //just because the client side is non-persistent it does not mean we want to close the connection to
                //the backend
                outboundResponseHeaders.put(Headers.CONNECTION, "keep-alive");
View Full Code Here

                        pushBackStreamSourceConduit.pushBack(pooled);
                    }

                } while (!state.isComplete());

                final ClientResponse response = builder.build();

                //check if an updated worked
                if (anyAreSet(HttpClientConnection.this.state, UPGRADE_REQUESTED)) {
                    String connectionString = response.getResponseHeaders().getFirst(CONNECTION);
                    if (!new HttpString(connectionString).equals(UPGRADE)) {
                        //just unset the upgrade requested flag
                        HttpClientConnection.this.state &= ~UPGRADE_REQUESTED;
                    }
                }
View Full Code Here

        }

        @Override
        public void completed(final ClientExchange result) {
            HttpServerExchange exchange = result.getAttachment(EXCHANGE);
            final ClientResponse response = result.getResponse();
            final HeaderMap inboundResponseHeaders = response.getResponseHeaders();
            final HeaderMap outboundResponseHeaders = exchange.getResponseHeaders();
            exchange.setResponseCode(response.getResponseCode());
            copyHeaders(outboundResponseHeaders, inboundResponseHeaders);

            if (exchange.isUpgrade()) {
                exchange.upgradeChannel(new ExchangeCompletionListener() {
                    @Override
View Full Code Here

    void setProtocol(final HttpString protocol) {
        this.protocol = protocol;
    }

    public ClientResponse build() {
      return new ClientResponse(statusCode, reasonPhrase, protocol, responseHeaders);
    }
View Full Code Here

    void setProtocol(final HttpString protocol) {
        this.protocol = protocol;
    }

    public ClientResponse build() {
      return new ClientResponse(statusCode, reasonPhrase, protocol, responseHeaders);
    }
View Full Code Here

                        buffer.clear();
                    }

                } while (!state.isComplete());

                final ClientResponse response = builder.build();

                //check if an updated worked
                if (anyAreSet(AjpClientConnection.this.state, UPGRADE_REQUESTED)) {
                    String connectionString = response.getResponseHeaders().getFirst(CONNECTION);
                    if (!new HttpString(connectionString).equals(UPGRADE)) {
                        //just unset the upgrade requested flag
                        AjpClientConnection.this.state &= ~UPGRADE_REQUESTED;
                    }
                }
View Full Code Here

        }

        @Override
        public void completed(final ClientExchange result) {
            HttpServerExchange exchange = result.getAttachment(EXCHANGE);
            final ClientResponse response = result.getResponse();
            final HeaderMap inboundResponseHeaders = response.getResponseHeaders();
            final HeaderMap outboundResponseHeaders = exchange.getResponseHeaders();
            exchange.setResponseCode(response.getResponseCode());
            copyHeaders(outboundResponseHeaders, inboundResponseHeaders);

            if (exchange.isUpgrade()) {
                exchange.upgradeChannel(new HttpUpgradeListener() {
                    @Override
View Full Code Here

TOP

Related Classes of io.undertow.client.ClientResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.