Package org.asynchttpclient.providers.netty

Examples of org.asynchttpclient.providers.netty.Callback


        pipeline.addAfter(WS_DECODER_HANDLER, WS_FRAME_AGGREGATOR, new WebSocketFrameAggregator(nettyConfig.getWebSocketMaxBufferSize()));
    }

    public final Callback newDrainCallback(final NettyResponseFuture<?> future, final Channel channel, final boolean keepAlive, final String poolKey) {

        return new Callback(future) {
            public void call() {
                tryToOfferChannelToPool(channel, keepAlive, poolKey);
            }
        };
    }
View Full Code Here


                            requestBuilder.addOrReplaceCookie(c);
                    }

                    requestBuilder.setHeaders(propagatedHeaders(future.getRequest()));

                    Callback callback = channelManager.newDrainCallback(future, channel, initialConnectionKeepAlive, initialPoolKey);

                    if (HttpHeaders.isTransferEncodingChunked(response)) {
                        // We must make sure there is no bytes left before
                        // executing the next request.
                        // FIXME investigate this
                        Channels.setAttribute(channel, callback);
                    } else {
                        // FIXME don't understand: this offers the connection to the pool, or even closes it, while the
                        // request has not been sent, right?
                        callback.call();
                    }

                    Request redirectRequest = requestBuilder.setUrl(newUrl).build();
                    // FIXME why not reuse the channel is same host?
                    requestSender.sendNextRequest(redirectRequest, future);
View Full Code Here

        Channel channel = ctx.channel();
        Object attribute = Channels.getAttribute(channel);

        if (attribute instanceof Callback && msg instanceof LastHttpContent) {
            Callback ac = (Callback) attribute;
            ac.call();
            Channels.setAttribute(channel, DiscardEvent.INSTANCE);

        } else if (attribute instanceof NettyResponseFuture) {
            NettyResponseFuture<?> future = (NettyResponseFuture<?>) attribute;
            protocol.handle(channel, future, msg);
View Full Code Here

        Object attribute = Channels.getAttribute(channel);
        LOGGER.debug("Channel Closed: {} with attribute {}", channel, attribute);

        if (attribute instanceof Callback) {
            Callback callback = (Callback) attribute;
            Channels.setAttribute(channel, callback.future());
            callback.call();

        } else if (attribute instanceof NettyResponseFuture<?>) {
            NettyResponseFuture<?> future = NettyResponseFuture.class.cast(attribute);
            future.touch();
View Full Code Here

                Realm nr = newRealm;
                final Request nextRequest = new RequestBuilder(future.getRequest()).setHeaders(request.getHeaders()).setRealm(nr).build();

                logger.debug("Sending authentication to {}", request.getUri());
                Callback callback = new Callback(future) {
                    public void call() throws IOException {
                        channelManager.drainChannel(channel, future);
                        requestSender.sendNextRequest(nextRequest, future);
                    }
                };

                if (future.isKeepAlive() && HttpHeaders.isTransferEncodingChunked(response))
                    // We must make sure there is no bytes left
                    // before executing the next request.
                    Channels.setAttribute(channel, callback);
                else
                    // call might crash with an IOException
                    callback.call();

                return true;
            }
        }
View Full Code Here

TOP

Related Classes of org.asynchttpclient.providers.netty.Callback

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.