com.ning.http.client.providers.netty
Class NettyAsyncHttpProvider
java.lang.Object
org.jboss.netty.channel.SimpleChannelUpstreamHandler
org.jboss.netty.handler.timeout.IdleStateHandler
com.ning.http.client.providers.netty.NettyAsyncHttpProvider
- All Implemented Interfaces:
- AsyncHttpProvider<org.jboss.netty.handler.codec.http.HttpResponse>, org.jboss.netty.channel.ChannelHandler, org.jboss.netty.channel.ChannelUpstreamHandler, org.jboss.netty.channel.LifeCycleAwareChannelHandler, org.jboss.netty.util.ExternalResourceReleasable
public class NettyAsyncHttpProvider
- extends org.jboss.netty.handler.timeout.IdleStateHandler
- implements AsyncHttpProvider<org.jboss.netty.handler.codec.http.HttpResponse>
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler |
org.jboss.netty.channel.ChannelHandler.Sharable |
Method Summary |
protected static boolean |
abortOnConnectCloseException(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,
URI uri,
boolean allowConnect,
org.jboss.netty.buffer.ChannelBuffer buffer)
|
void |
channelClosed(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ChannelStateEvent e)
|
protected void |
channelIdle(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.handler.timeout.IdleState state,
long lastActivityTimeMillis)
|
void |
close()
Close the current underlying TCP/HTTP connection.s |
void |
exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ExceptionEvent e)
|
|
execute(Request request,
AsyncHandler<T> asyncHandler)
Execute the request and invoke the AsyncHandler when the response arrive. |
void |
messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.MessageEvent e)
|
Response |
prepareResponse(HttpResponseStatus status,
HttpResponseHeaders headers,
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)
|
protected
|
writeRequest(org.jboss.netty.channel.Channel channel,
AsyncHttpClientConfig config,
NettyResponseFuture<T> future,
org.jboss.netty.handler.codec.http.HttpRequest nettyRequest)
|
Methods inherited from class org.jboss.netty.handler.timeout.IdleStateHandler |
afterAdd, afterRemove, beforeAdd, beforeRemove, channelOpen, releaseExternalResources, writeComplete |
Methods inherited from class org.jboss.netty.channel.SimpleChannelUpstreamHandler |
channelBound, channelConnected, channelDisconnected, channelInterestChanged, channelUnbound, childChannelClosed, childChannelOpen, handleUpstream |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IN_IO_THREAD
public static final ThreadLocal<Boolean> IN_IO_THREAD
NettyAsyncHttpProvider
public NettyAsyncHttpProvider(AsyncHttpClientConfig config)
writeRequest
protected final <T> void writeRequest(org.jboss.netty.channel.Channel channel,
AsyncHttpClientConfig config,
NettyResponseFuture<T> future,
org.jboss.netty.handler.codec.http.HttpRequest nettyRequest)
buildRequest
protected static final org.jboss.netty.handler.codec.http.HttpRequest buildRequest(AsyncHttpClientConfig config,
Request request,
URI uri,
boolean allowConnect,
org.jboss.netty.buffer.ChannelBuffer buffer)
throws IOException
- Throws:
IOException
close
public void close()
- Description copied from interface:
AsyncHttpProvider
- Close the current underlying TCP/HTTP connection.s
- Specified by:
close
in interface AsyncHttpProvider<org.jboss.netty.handler.codec.http.HttpResponse>
prepareResponse
public Response prepareResponse(HttpResponseStatus status,
HttpResponseHeaders headers,
Collection<HttpResponseBodyPart> bodyParts)
- Description copied from interface:
AsyncHttpProvider
- Prepare a
Response
- Specified by:
prepareResponse
in interface AsyncHttpProvider<org.jboss.netty.handler.codec.http.HttpResponse>
- Parameters:
status
- HttpResponseStatus
headers
- HttpResponseHeaders
bodyParts
- list of HttpResponseBodyPart
- Returns:
- a
Response
execute
public <T> Future<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<org.jboss.netty.handler.codec.http.HttpResponse>
asyncHandler
- an instance of AsyncHandler
- Returns:
- a
Future
of Type T.
- Throws:
IOException
requestTimeout
protected static int requestTimeout(AsyncHttpClientConfig config,
PerRequestConfig perRequestConfig)
channelIdle
protected void channelIdle(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.handler.timeout.IdleState state,
long lastActivityTimeMillis)
throws Exception
- Overrides:
channelIdle
in class org.jboss.netty.handler.timeout.IdleStateHandler
- Throws:
Exception
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.handler.timeout.IdleStateHandler
- Throws:
Exception
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.handler.timeout.IdleStateHandler
- 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)
abortOnReadCloseException
protected static boolean abortOnReadCloseException(Throwable cause)
abortOnWriteCloseException
protected static boolean abortOnWriteCloseException(Throwable cause)
Copyright © 2010. All Rights Reserved.