com.ning.http.client.providers.netty
public class NettyAsyncHttpProvider extends org.jboss.netty.channel.SimpleChannelUpstreamHandler implements AsyncHttpProvider
Modifier and Type | Class and Description |
---|---|
static class |
NettyAsyncHttpProvider.OptimizedFileRegion |
static class |
NettyAsyncHttpProvider.ThreadLocalBoolean |
Modifier and Type | Field and Description |
---|---|
static java.lang.ThreadLocal<java.lang.Boolean> |
IN_IO_THREAD |
Constructor and Description |
---|
NettyAsyncHttpProvider(AsyncHttpClientConfig config) |
Modifier and Type | Method and Description |
---|---|
protected static boolean |
abortOnConnectCloseException(java.lang.Throwable cause) |
protected static boolean |
abortOnDisconnectException(java.lang.Throwable cause) |
protected static boolean |
abortOnReadCloseException(java.lang.Throwable cause) |
protected static boolean |
abortOnWriteCloseException(java.lang.Throwable cause) |
protected static org.jboss.netty.handler.codec.http.HttpRequest |
buildRequest(AsyncHttpClientConfig config,
Request request,
java.net.URI uri,
boolean allowConnect,
org.jboss.netty.buffer.ChannelBuffer buffer) |
void |
channelClosed(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ChannelStateEvent e) |
void |
close()
Close the current underlying TCP/HTTP connection.
|
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() |
void |
messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.MessageEvent e) |
static <T> NettyResponseFuture<T> |
newFuture(java.net.URI uri,
Request request,
AsyncHandler<T> asyncHandler,
org.jboss.netty.handler.codec.http.HttpRequest nettyRequest,
AsyncHttpClientConfig config,
NettyAsyncHttpProvider provider) |
Response |
prepareResponse(HttpResponseStatus status,
HttpResponseHeaders headers,
java.util.Collection<HttpResponseBodyPart> bodyParts)
Prepare a
Response |
protected boolean |
remotelyClosed(org.jboss.netty.channel.Channel channel,
NettyResponseFuture<?> future) |
protected static int |
requestTimeout(AsyncHttpClientConfig config,
PerRequestConfig perRequestConfig) |
java.lang.String |
toString() |
protected <T> void |
writeRequest(org.jboss.netty.channel.Channel channel,
AsyncHttpClientConfig config,
NettyResponseFuture<T> future,
org.jboss.netty.handler.codec.http.HttpRequest nettyRequest) |
public NettyAsyncHttpProvider(AsyncHttpClientConfig config)
public java.lang.String toString()
toString
in class java.lang.Object
protected final <T> void writeRequest(org.jboss.netty.channel.Channel channel, AsyncHttpClientConfig config, NettyResponseFuture<T> future, org.jboss.netty.handler.codec.http.HttpRequest nettyRequest)
protected static final org.jboss.netty.handler.codec.http.HttpRequest buildRequest(AsyncHttpClientConfig config, Request request, java.net.URI uri, boolean allowConnect, org.jboss.netty.buffer.ChannelBuffer buffer) throws java.io.IOException
java.io.IOException
public void close()
AsyncHttpProvider
close
in interface AsyncHttpProvider
public Response prepareResponse(HttpResponseStatus status, HttpResponseHeaders headers, java.util.Collection<HttpResponseBodyPart> bodyParts)
AsyncHttpProvider
Response
prepareResponse
in interface AsyncHttpProvider
status
- HttpResponseStatus
headers
- HttpResponseHeaders
bodyParts
- list of HttpResponseBodyPart
Response
public <T> ListenableFuture<T> execute(Request request, AsyncHandler<T> asyncHandler) throws java.io.IOException
AsyncHttpProvider
AsyncHandler
when the response arrive.execute
in interface AsyncHttpProvider
asyncHandler
- an instance of AsyncHandler
ListenableFuture
of Type T.java.io.IOException
protected static int requestTimeout(AsyncHttpClientConfig config, PerRequestConfig perRequestConfig)
public void messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.MessageEvent e) throws java.lang.Exception
messageReceived
in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
java.lang.Exception
public void channelClosed(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.ChannelStateEvent e) throws java.lang.Exception
channelClosed
in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
java.lang.Exception
protected boolean remotelyClosed(org.jboss.netty.channel.Channel channel, NettyResponseFuture<?> future)
public void exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.ExceptionEvent e) throws java.lang.Exception
exceptionCaught
in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
java.lang.Exception
protected static boolean abortOnConnectCloseException(java.lang.Throwable cause)
protected static boolean abortOnDisconnectException(java.lang.Throwable cause)
protected static boolean abortOnReadCloseException(java.lang.Throwable cause)
protected static boolean abortOnWriteCloseException(java.lang.Throwable cause)
public static <T> NettyResponseFuture<T> newFuture(java.net.URI uri, Request request, AsyncHandler<T> asyncHandler, org.jboss.netty.handler.codec.http.HttpRequest nettyRequest, AsyncHttpClientConfig config, NettyAsyncHttpProvider provider)
protected AsyncHttpClientConfig getConfig()
Copyright © 2014. All Rights Reserved.