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
Handler that establishes a blind forwarding proxy tunnel using
HTTP/1.1 CONNECT request. It can be used to
establish plaintext or secure tunnels.
HTTP users who need to connect to a message-forwarding HTTP proxy agent instead of a tunneling proxy should not use this handler.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
static final class
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
FieldsModifier and TypeFieldDescriptionprivate static final String
private final CharSequence
private final HttpProxyHandler.HttpClientCodecWrapper
private final boolean
private HttpHeaders
private final HttpHeaders
private final String
private static final String
private HttpResponseStatus
private final String
Fields inherited from class io.netty.handler.proxy.ProxyHandler
AUTH_NONE
-
Constructor Summary
ConstructorsConstructorDescriptionHttpProxyHandler
(SocketAddress proxyAddress) HttpProxyHandler
(SocketAddress proxyAddress, HttpHeaders headers) HttpProxyHandler
(SocketAddress proxyAddress, HttpHeaders headers, boolean ignoreDefaultPortsInConnectHostHeader) HttpProxyHandler
(SocketAddress proxyAddress, String username, String password) HttpProxyHandler
(SocketAddress proxyAddress, String username, String password, HttpHeaders headers) HttpProxyHandler
(SocketAddress proxyAddress, String username, String password, HttpHeaders headers, boolean ignoreDefaultPortsInConnectHostHeader) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Adds the codec handlers required to communicate with the proxy server.Returns the name of the authentication scheme in use.protected boolean
handleResponse
(ChannelHandlerContext ctx, Object response) Handles the message received from the proxy server.protected Object
Returns a new message that is sent at first time when the connection to the proxy server has been established.password()
protocol()
Returns the name of the proxy protocol in use.protected void
Removes the decoders added inProxyHandler.addCodec(ChannelHandlerContext)
.protected void
Removes the encoders added inProxyHandler.addCodec(ChannelHandlerContext)
.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 Details
-
PROTOCOL
- See Also:
-
AUTH_BASIC
- See Also:
-
codecWrapper
-
username
-
password
-
authorization
-
outboundHeaders
-
ignoreDefaultPortsInConnectHostHeader
private final boolean ignoreDefaultPortsInConnectHostHeader -
status
-
inboundHeaders
-
-
Constructor Details
-
HttpProxyHandler
-
HttpProxyHandler
-
HttpProxyHandler
public HttpProxyHandler(SocketAddress proxyAddress, HttpHeaders headers, boolean ignoreDefaultPortsInConnectHostHeader) -
HttpProxyHandler
-
HttpProxyHandler
public HttpProxyHandler(SocketAddress proxyAddress, String username, String password, HttpHeaders headers) -
HttpProxyHandler
public HttpProxyHandler(SocketAddress proxyAddress, String username, String password, HttpHeaders headers, boolean ignoreDefaultPortsInConnectHostHeader)
-
-
Method Details
-
protocol
Description copied from class:ProxyHandler
Returns the name of the proxy protocol in use.- Specified by:
protocol
in classProxyHandler
-
authScheme
Description copied from class:ProxyHandler
Returns the name of the authentication scheme in use.- Specified by:
authScheme
in classProxyHandler
-
username
-
password
-
addCodec
Description copied from class:ProxyHandler
Adds the codec handlers required to communicate with the proxy server.- Specified by:
addCodec
in classProxyHandler
- Throws:
Exception
-
removeEncoder
Description copied from class:ProxyHandler
Removes the encoders added inProxyHandler.addCodec(ChannelHandlerContext)
.- Specified by:
removeEncoder
in classProxyHandler
- Throws:
Exception
-
removeDecoder
Description copied from class:ProxyHandler
Removes the decoders added inProxyHandler.addCodec(ChannelHandlerContext)
.- Specified by:
removeDecoder
in classProxyHandler
- Throws:
Exception
-
newInitialMessage
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:
Exception
-
handleResponse
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:
Exception
-