com.ning.http.client.providers.netty
Class NettyAsyncHttpProvider

java.lang.Object
  extended by org.jboss.netty.channel.SimpleChannelUpstreamHandler
      extended by com.ning.http.client.providers.netty.NettyAsyncHttpProvider
All Implemented Interfaces:
AsyncHttpProvider, org.jboss.netty.channel.ChannelHandler, org.jboss.netty.channel.ChannelUpstreamHandler

public class NettyAsyncHttpProvider
extends org.jboss.netty.channel.SimpleChannelUpstreamHandler
implements AsyncHttpProvider


Nested Class Summary
static class NettyAsyncHttpProvider.OptimizedFileRegion
           
static class NettyAsyncHttpProvider.ThreadLocalBoolean
           
 
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
org.jboss.netty.channel.ChannelHandler.Sharable
 
Field Summary
static String GZIP_DEFLATE
           
static String HTTP_HANDLER
           
static String HTTP_PROCESSOR
           
static ThreadLocal<Boolean> IN_IO_THREAD
           
static IOException REMOTELY_CLOSED_EXCEPTION
           
static String SSL_HANDLER
           
static String WS_PROCESSOR
           
 
Constructor Summary
NettyAsyncHttpProvider(AsyncHttpClientConfig config)
           
 
Method Summary
 void abort(NettyResponseFuture<?> future, Throwable t)
           
protected static boolean abortOnConnectCloseException(Throwable cause)
           
protected static boolean abortOnDisconnectException(Throwable cause)
           
protected static boolean abortOnReadCloseException(Throwable cause)
           
protected static boolean abortOnWriteCloseException(Throwable cause)
           
protected static org.jboss.netty.handler.codec.http.HttpRequest buildRequest(AsyncHttpClientConfig config, Request request, UriComponents uri, boolean allowConnect, org.jboss.netty.buffer.ChannelBuffer buffer, ProxyServer proxyServer)
           
 void channelClosed(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.ChannelStateEvent e)
           
 void close()
          Close the current underlying TCP/HTTP connection.
protected  void configureHttpClientCodec()
           
protected  void configureHttpsClientCodec()
           
 void exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.ExceptionEvent e)
           
<T> ListenableFuture<T>
execute(Request request, AsyncHandler<T> asyncHandler)
          Execute the request and invoke the AsyncHandler when the response arrive.
protected  AsyncHttpClientConfig getConfig()
           
 boolean isClose()
           
 void messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.MessageEvent e)
           
static
<T> NettyResponseFuture<T>
newFuture(UriComponents uri, Request request, AsyncHandler<T> asyncHandler, org.jboss.netty.handler.codec.http.HttpRequest nettyRequest, AsyncHttpClientConfig config, NettyAsyncHttpProvider provider, ProxyServer proxyServer)
           
 org.jboss.netty.util.Timeout newTimeoutInMs(org.jboss.netty.util.TimerTask task, long delayInMs)
           
 Response prepareResponse(HttpResponseStatus status, HttpResponseHeaders headers, List<HttpResponseBodyPart> bodyParts)
          Prepare a Response
protected  boolean remotelyClosed(org.jboss.netty.channel.Channel channel, NettyResponseFuture<?> future)
           
 String toString()
           
protected
<T> void
writeRequest(org.jboss.netty.channel.Channel channel, AsyncHttpClientConfig config, NettyResponseFuture<T> future)
           
 
Methods inherited from class org.jboss.netty.channel.SimpleChannelUpstreamHandler
channelBound, channelConnected, channelDisconnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, handleUpstream, writeComplete
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

GZIP_DEFLATE

public static final String GZIP_DEFLATE
See Also:
Constant Field Values

REMOTELY_CLOSED_EXCEPTION

public static final IOException REMOTELY_CLOSED_EXCEPTION

HTTP_HANDLER

public static final String HTTP_HANDLER
See Also:
Constant Field Values

SSL_HANDLER

public static final String SSL_HANDLER
See Also:
Constant Field Values

HTTP_PROCESSOR

public static final String HTTP_PROCESSOR
See Also:
Constant Field Values

WS_PROCESSOR

public static final String WS_PROCESSOR
See Also:
Constant Field Values

IN_IO_THREAD

public static final ThreadLocal<Boolean> IN_IO_THREAD
Constructor Detail

NettyAsyncHttpProvider

public NettyAsyncHttpProvider(AsyncHttpClientConfig config)
Method Detail

toString

public String toString()
Overrides:
toString in class Object

configureHttpClientCodec

protected void configureHttpClientCodec()

configureHttpsClientCodec

protected void configureHttpsClientCodec()

writeRequest

protected final <T> void writeRequest(org.jboss.netty.channel.Channel channel,
                                      AsyncHttpClientConfig config,
                                      NettyResponseFuture<T> future)

buildRequest

protected static final org.jboss.netty.handler.codec.http.HttpRequest buildRequest(AsyncHttpClientConfig config,
                                                                                   Request request,
                                                                                   UriComponents uri,
                                                                                   boolean allowConnect,
                                                                                   org.jboss.netty.buffer.ChannelBuffer buffer,
                                                                                   ProxyServer proxyServer)
                                                                            throws IOException
Throws:
IOException

close

public void close()
Description copied from interface: AsyncHttpProvider
Close the current underlying TCP/HTTP connection.

Specified by:
close in interface AsyncHttpProvider

prepareResponse

public Response prepareResponse(HttpResponseStatus status,
                                HttpResponseHeaders headers,
                                List<HttpResponseBodyPart> bodyParts)
Description copied from interface: AsyncHttpProvider
Prepare a Response

Specified by:
prepareResponse in interface AsyncHttpProvider
Parameters:
status - HttpResponseStatus
headers - HttpResponseHeaders
bodyParts - list of HttpResponseBodyPart
Returns:
a Response

execute

public <T> ListenableFuture<T> execute(Request request,
                                       AsyncHandler<T> asyncHandler)
                            throws IOException
Description copied from interface: AsyncHttpProvider
Execute the request and invoke the AsyncHandler when the response arrive.

Specified by:
execute in interface AsyncHttpProvider
asyncHandler - an instance of AsyncHandler
Returns:
a ListenableFuture of Type T.
Throws:
IOException

messageReceived

public void messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx,
                            org.jboss.netty.channel.MessageEvent e)
                     throws Exception
Overrides:
messageReceived in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
Throws:
Exception

abort

public void abort(NettyResponseFuture<?> future,
                  Throwable t)

channelClosed

public void channelClosed(org.jboss.netty.channel.ChannelHandlerContext ctx,
                          org.jboss.netty.channel.ChannelStateEvent e)
                   throws Exception
Overrides:
channelClosed in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
Throws:
Exception

remotelyClosed

protected boolean remotelyClosed(org.jboss.netty.channel.Channel channel,
                                 NettyResponseFuture<?> future)

exceptionCaught

public void exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx,
                            org.jboss.netty.channel.ExceptionEvent e)
                     throws Exception
Overrides:
exceptionCaught in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
Throws:
Exception

abortOnConnectCloseException

protected static boolean abortOnConnectCloseException(Throwable cause)

abortOnDisconnectException

protected static boolean abortOnDisconnectException(Throwable cause)

abortOnReadCloseException

protected static boolean abortOnReadCloseException(Throwable cause)

abortOnWriteCloseException

protected static boolean abortOnWriteCloseException(Throwable cause)

newFuture

public static <T> NettyResponseFuture<T> newFuture(UriComponents uri,
                                                   Request request,
                                                   AsyncHandler<T> asyncHandler,
                                                   org.jboss.netty.handler.codec.http.HttpRequest nettyRequest,
                                                   AsyncHttpClientConfig config,
                                                   NettyAsyncHttpProvider provider,
                                                   ProxyServer proxyServer)

getConfig

protected AsyncHttpClientConfig getConfig()

isClose

public boolean isClose()

newTimeoutInMs

public org.jboss.netty.util.Timeout newTimeoutInMs(org.jboss.netty.util.TimerTask task,
                                                   long delayInMs)


Copyright © 2014. All Rights Reserved.