Package io.undertow.client

Examples of io.undertow.client.HttpClientRequest


            this.serverConnection = serverConnection;
        }

        @Override
        public void run() {
            final HttpClientRequest request;
            try {
                String requestURI = exchange.getRequestURI();
                String qs = exchange.getQueryString();
                if (qs != null && !qs.isEmpty()) {
                    requestURI += "?" + qs;
                }
                request = clientConnection.createRequest(exchange.getRequestMethod(), new URI(requestURI));
            } catch (URISyntaxException e) {
                exchange.setResponseCode(500);
                exchange.endExchange();
                return;
            }
            final HeaderMap inboundRequestHeaders = exchange.getRequestHeaders();
            final HeaderMap outboundRequestHeaders = request.getRequestHeaders();
            copyHeaders(outboundRequestHeaders, inboundRequestHeaders);
            final long requestContentLength = exchange.getRequestContentLength();

            if (HttpContinue.requiresContinueResponse(exchange)) {
                request.setContinueHandler(new HttpContinueNotification() {
                    @Override
                    public void handleContinue(final ContinueContext context) {
                        HttpContinue.sendContinueResponse(exchange, new IoCallback() {
                            @Override
                            public void onComplete(final HttpServerExchange exchange, final Sender sender) {
                                context.done();
                            }

                            @Override
                            public void onException(final HttpServerExchange exchange, final Sender sender, final IOException exception) {
                                context.done();
                            }
                        });
                    }
                });
            }


            if (requestContentLength == 0L || exchange.getRequestMethod().equals(Methods.GET)) {
                request.writeRequestBody(0L);
            } else {
                ChannelListeners.initiateTransfer(Long.MAX_VALUE, exchange.getRequestChannel(), request.writeRequestBody(requestContentLength), ChannelListeners.closingChannelListener(), new HTTPTrailerChannelListener(exchange, request), ChannelListeners.closingChannelExceptionHandler(), ChannelListeners.closingChannelExceptionHandler(), exchange.getConnection().getBufferPool());
            }
            final IoFuture<HttpClientResponse> futureResponse = request.getResponse();
            futureResponse.addNotifier(RESPONSE_NOTIFIER, exchange);
        }
View Full Code Here


            this.serverConnection = serverConnection;
        }

        @Override
        public void run() {
            final HttpClientRequest request;
            try {
                String requestURI = exchange.getRequestURI();
                String qs = exchange.getQueryString();
                if (qs != null && !qs.isEmpty()) {
                    requestURI += "?" + qs;
                }
                request = clientConnection.createRequest(exchange.getRequestMethod(), new URI(requestURI));
            } catch (URISyntaxException e) {
                exchange.setResponseCode(500);
                exchange.endExchange();
                return;
            }
            final HeaderMap inboundRequestHeaders = exchange.getRequestHeaders();
            final HeaderMap outboundRequestHeaders = request.getRequestHeaders();
            copyHeaders(outboundRequestHeaders, inboundRequestHeaders);
            final long requestContentLength = exchange.getRequestContentLength();

            if(HttpContinue.requiresContinueResponse(exchange)) {
                request.setContinueHandler(new HttpContinueNotification() {
                    @Override
                    public void handleContinue(final ContinueContext context) {
                        HttpContinue.sendContinueResponse(exchange, new IoCallback() {
                            @Override
                            public void onComplete(final HttpServerExchange exchange, final Sender sender) {
                                context.done();
                            }

                            @Override
                            public void onException(final HttpServerExchange exchange, final Sender sender, final IOException exception) {
                                context.done();
                            }
                        });
                    }
                });
            }



            if (requestContentLength == 0L || exchange.getRequestMethod().equals(Methods.GET)) {
                request.writeRequestBody(0L);
            } else {
                ChannelListeners.initiateTransfer(Long.MAX_VALUE, exchange.getRequestChannel(), request.writeRequestBody(requestContentLength), ChannelListeners.closingChannelListener(), new HTTPTrailerChannelListener(exchange, request), ChannelListeners.closingChannelExceptionHandler(), ChannelListeners.closingChannelExceptionHandler(), exchange.getConnection().getBufferPool());
            }
            final IoFuture<HttpClientResponse> futureResponse = request.getResponse();
            futureResponse.addNotifier(RESPONSE_NOTIFIER, exchange);
        }
View Full Code Here

        InetSocketAddress address = new InetSocketAddress(uri.getHost(), uri.getPort());
        client.connect(address, optionMap, new HttpClientCallback<HttpClientConnection>() {
            @Override
            public void completed(final HttpClientConnection connection) {
                final WebSocketClientHandshake handshake = WebSocketClientHandshake.create(WebSocketVersion.V13, uri);
                HttpClientRequest request = connection.createRequest(Methods.GET, uri);
                handshake.setupRequest(request);
                request.writeRequest(new HttpClientCallback<HttpClientResponse>() {
                    @Override
                    public void completed(final HttpClientResponse result) {
                        try {
                            handshake.verifyResponse(uri, result, connection, callback);
                        } catch (IOException e) {
View Full Code Here

            this.serverConnection = serverConnection;
        }

        @Override
        public void run() {
            final HttpClientRequest request;
            try {
                String requestURI = exchange.getRequestURI();
                String qs = exchange.getQueryString();
                if (qs != null && !qs.isEmpty()) {
                    requestURI += "?" + qs;
                }
                request = clientConnection.createRequest(exchange.getRequestMethod(), new URI(requestURI));
            } catch (URISyntaxException e) {
                exchange.setResponseCode(500);
                exchange.endExchange();
                return;
            }
            final HeaderMap inboundRequestHeaders = exchange.getRequestHeaders();
            final HeaderMap outboundRequestHeaders = request.getRequestHeaders();
            copyHeaders(outboundRequestHeaders, inboundRequestHeaders);
            final long requestContentLength = exchange.getRequestContentLength();

            if (HttpContinue.requiresContinueResponse(exchange)) {
                request.setContinueHandler(new HttpContinueNotification() {
                    @Override
                    public void handleContinue(final ContinueContext context) {
                        HttpContinue.sendContinueResponse(exchange, new IoCallback() {
                            @Override
                            public void onComplete(final HttpServerExchange exchange, final Sender sender) {
                                context.done();
                            }

                            @Override
                            public void onException(final HttpServerExchange exchange, final Sender sender, final IOException exception) {
                                context.done();
                            }
                        });
                    }
                });
            }


            if (requestContentLength == 0L || exchange.getRequestMethod().equals(Methods.GET)) {
                request.writeRequestBody(0L);
            } else {
                ChannelListeners.initiateTransfer(Long.MAX_VALUE, exchange.getRequestChannel(), request.writeRequestBody(requestContentLength), ChannelListeners.closingChannelListener(), new HTTPTrailerChannelListener(exchange, request), ChannelListeners.closingChannelExceptionHandler(), ChannelListeners.closingChannelExceptionHandler(), exchange.getConnection().getBufferPool());
            }
            final IoFuture<HttpClientResponse> futureResponse = request.getResponse();
            futureResponse.addNotifier(RESPONSE_NOTIFIER, exchange);
        }
View Full Code Here

        InetSocketAddress address = new InetSocketAddress(uri.getHost(), uri.getPort());
        client.connect(address, optionMap, new HttpClientCallback<HttpClientConnection>() {
            @Override
            public void completed(final HttpClientConnection connection) {
                final WebSocketClientHandshake handshake = WebSocketClientHandshake.create(WebSocketVersion.V13, uri);
                HttpClientRequest request = connection.createRequest(Methods.GET, uri);
                handshake.setupRequest(request);
                request.writeRequest(new HttpClientCallback<HttpClientResponse>() {
                    @Override
                    public void completed(final HttpClientResponse result) {
                        try {
                            handshake.verifyResponse(uri, result, connection, callback);
                        } catch (IOException e) {
View Full Code Here

            this.serverConnection = serverConnection;
        }

        @Override
        public void run() {
            final HttpClientRequest request;
            try {
                String requestURI = exchange.getRequestURI();
                String qs = exchange.getQueryString();
                if (qs != null && !qs.isEmpty()) {
                    requestURI += "?" + qs;
                }
                request = clientConnection.createRequest(exchange.getRequestMethod(), new URI(requestURI));
            } catch (URISyntaxException e) {
                exchange.setResponseCode(500);
                exchange.endExchange();
                return;
            }
            final HeaderMap inboundRequestHeaders = exchange.getRequestHeaders();
            final HeaderMap outboundRequestHeaders = request.getRequestHeaders();
            copyHeaders(outboundRequestHeaders, inboundRequestHeaders);
            final long requestContentLength = exchange.getRequestContentLength();

            if(HttpContinue.requiresContinueResponse(exchange)) {
                request.setContinueHandler(new HttpContinueNotification() {
                    @Override
                    public void handleContinue(final ContinueContext context) {
                        HttpContinue.sendContinueResponse(exchange, new IoCallback() {
                            @Override
                            public void onComplete(final HttpServerExchange exchange, final Sender sender) {
                                context.done();
                            }

                            @Override
                            public void onException(final HttpServerExchange exchange, final Sender sender, final IOException exception) {
                                context.done();
                            }
                        });
                    }
                });
            }



            if (requestContentLength == 0L || exchange.getRequestMethod().equals(Methods.GET)) {
                request.writeRequestBody(0L);
            } else {
                ChannelListeners.initiateTransfer(Long.MAX_VALUE, exchange.getRequestChannel(), request.writeRequestBody(requestContentLength), ChannelListeners.closingChannelListener(), new HTTPTrailerChannelListener(exchange, request), ChannelListeners.closingChannelExceptionHandler(), ChannelListeners.closingChannelExceptionHandler(), exchange.getConnection().getBufferPool());
            }
            final IoFuture<HttpClientResponse> futureResponse = request.getResponse();
            futureResponse.addNotifier(RESPONSE_NOTIFIER, exchange);
        }
View Full Code Here

TOP

Related Classes of io.undertow.client.HttpClientRequest

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.