Package io.netty.handler.proxy
Class HttpProxyHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.channel.ChannelDuplexHandler
-
- io.netty.handler.proxy.ProxyHandler
-
- io.netty.handler.proxy.HttpProxyHandler
-
- All Implemented Interfaces:
ChannelHandler
,ChannelInboundHandler
,ChannelOutboundHandler
public final class HttpProxyHandler extends ProxyHandler
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
HttpProxyHandler.HttpClientCodecWrapper
static class
HttpProxyHandler.HttpProxyConnectException
Specific case of a connection failure, which may include headers from the proxy.-
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
AUTH_BASIC
private java.lang.CharSequence
authorization
private HttpProxyHandler.HttpClientCodecWrapper
codecWrapper
private boolean
ignoreDefaultPortsInConnectHostHeader
private HttpHeaders
inboundHeaders
private HttpHeaders
outboundHeaders
private java.lang.String
password
private static java.lang.String
PROTOCOL
private HttpResponseStatus
status
private java.lang.String
username
-
Fields inherited from class io.netty.handler.proxy.ProxyHandler
AUTH_NONE
-
-
Constructor Summary
Constructors Constructor Description HttpProxyHandler(java.net.SocketAddress proxyAddress)
HttpProxyHandler(java.net.SocketAddress proxyAddress, HttpHeaders headers)
HttpProxyHandler(java.net.SocketAddress proxyAddress, HttpHeaders headers, boolean ignoreDefaultPortsInConnectHostHeader)
HttpProxyHandler(java.net.SocketAddress proxyAddress, java.lang.String username, java.lang.String password)
HttpProxyHandler(java.net.SocketAddress proxyAddress, java.lang.String username, java.lang.String password, HttpHeaders headers)
HttpProxyHandler(java.net.SocketAddress proxyAddress, java.lang.String username, java.lang.String password, HttpHeaders headers, boolean ignoreDefaultPortsInConnectHostHeader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addCodec(ChannelHandlerContext ctx)
Adds the codec handlers required to communicate with the proxy server.java.lang.String
authScheme()
Returns the name of the authentication scheme in use.protected boolean
handleResponse(ChannelHandlerContext ctx, java.lang.Object response)
Handles the message received from the proxy server.protected java.lang.Object
newInitialMessage(ChannelHandlerContext ctx)
Returns a new message that is sent at first time when the connection to the proxy server has been established.java.lang.String
password()
java.lang.String
protocol()
Returns the name of the proxy protocol in use.protected void
removeDecoder(ChannelHandlerContext ctx)
Removes the decoders added inProxyHandler.addCodec(ChannelHandlerContext)
.protected void
removeEncoder(ChannelHandlerContext ctx)
Removes the encoders added inProxyHandler.addCodec(ChannelHandlerContext)
.java.lang.String
username()
-
Methods inherited from class io.netty.handler.proxy.ProxyHandler
channelActive, channelInactive, channelRead, channelReadComplete, connect, connectFuture, connectTimeoutMillis, destinationAddress, exceptionCaught, exceptionMessage, flush, handlerAdded, isConnected, proxyAddress, sendToProxyServer, setConnectTimeoutMillis, write
-
Methods inherited from class io.netty.channel.ChannelDuplexHandler
bind, close, deregister, disconnect, read
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerRemoved, isSharable
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.channel.ChannelHandler
handlerRemoved
-
-
-
-
Field Detail
-
PROTOCOL
private static final java.lang.String PROTOCOL
- See Also:
- Constant Field Values
-
AUTH_BASIC
private static final java.lang.String AUTH_BASIC
- See Also:
- Constant Field Values
-
codecWrapper
private final HttpProxyHandler.HttpClientCodecWrapper codecWrapper
-
username
private final java.lang.String username
-
password
private final java.lang.String password
-
authorization
private final java.lang.CharSequence authorization
-
outboundHeaders
private final HttpHeaders outboundHeaders
-
ignoreDefaultPortsInConnectHostHeader
private final boolean ignoreDefaultPortsInConnectHostHeader
-
status
private HttpResponseStatus status
-
inboundHeaders
private HttpHeaders inboundHeaders
-
-
Constructor Detail
-
HttpProxyHandler
public HttpProxyHandler(java.net.SocketAddress proxyAddress)
-
HttpProxyHandler
public HttpProxyHandler(java.net.SocketAddress proxyAddress, HttpHeaders headers)
-
HttpProxyHandler
public HttpProxyHandler(java.net.SocketAddress proxyAddress, HttpHeaders headers, boolean ignoreDefaultPortsInConnectHostHeader)
-
HttpProxyHandler
public HttpProxyHandler(java.net.SocketAddress proxyAddress, java.lang.String username, java.lang.String password)
-
HttpProxyHandler
public HttpProxyHandler(java.net.SocketAddress proxyAddress, java.lang.String username, java.lang.String password, HttpHeaders headers)
-
HttpProxyHandler
public HttpProxyHandler(java.net.SocketAddress proxyAddress, java.lang.String username, java.lang.String password, HttpHeaders headers, boolean ignoreDefaultPortsInConnectHostHeader)
-
-
Method Detail
-
protocol
public java.lang.String protocol()
Description copied from class:ProxyHandler
Returns the name of the proxy protocol in use.- Specified by:
protocol
in classProxyHandler
-
authScheme
public java.lang.String authScheme()
Description copied from class:ProxyHandler
Returns the name of the authentication scheme in use.- Specified by:
authScheme
in classProxyHandler
-
username
public java.lang.String username()
-
password
public java.lang.String password()
-
addCodec
protected void addCodec(ChannelHandlerContext ctx) throws java.lang.Exception
Description copied from class:ProxyHandler
Adds the codec handlers required to communicate with the proxy server.- Specified by:
addCodec
in classProxyHandler
- Throws:
java.lang.Exception
-
removeEncoder
protected void removeEncoder(ChannelHandlerContext ctx) throws java.lang.Exception
Description copied from class:ProxyHandler
Removes the encoders added inProxyHandler.addCodec(ChannelHandlerContext)
.- Specified by:
removeEncoder
in classProxyHandler
- Throws:
java.lang.Exception
-
removeDecoder
protected void removeDecoder(ChannelHandlerContext ctx) throws java.lang.Exception
Description copied from class:ProxyHandler
Removes the decoders added inProxyHandler.addCodec(ChannelHandlerContext)
.- Specified by:
removeDecoder
in classProxyHandler
- Throws:
java.lang.Exception
-
newInitialMessage
protected java.lang.Object newInitialMessage(ChannelHandlerContext ctx) throws java.lang.Exception
Description copied from class:ProxyHandler
Returns a new message that is sent at first time when the connection to the proxy server has been established.- Specified by:
newInitialMessage
in classProxyHandler
- Returns:
- the initial message, or
null
if the proxy server is expected to send the first message instead - Throws:
java.lang.Exception
-
handleResponse
protected boolean handleResponse(ChannelHandlerContext ctx, java.lang.Object response) throws java.lang.Exception
Description copied from class:ProxyHandler
Handles the message received from the proxy server.- Specified by:
handleResponse
in classProxyHandler
- Returns:
true
if the connection to the destination has been established,false
if the connection to the destination has not been established and more messages are expected from the proxy server- Throws:
java.lang.Exception
-
-