I - the type of "initial" message. This will be either HttpResponse or HttpRequest.public abstract class HttpProxyConnection<I extends io.netty.handler.codec.http.HttpObject> extends ProxyConnection<Object>
Base class for objects that represent a connection to/from our proxy.
A ProxyConnection models a bidirectional message flow on top of a Netty Channel.
The readProxyIncoming(Object) method is called whenever a new message arrives on the underlying socket.
The writeToChannel(Object) method can be called by anyone wanting to write data out of the connection.
ProxyConnection has a lifecycle and its current state within that lifecycle is recorded as a ConnectionState.
The allowed states and transitions vary a little depending on the concrete implementation of ProxyConnection.
However, all ProxyConnections share the following lifecycle events:
connected() - Once the underlying channel is active, the ProxyConnection is considered connected and
moves into ConnectionState.AWAITING_INITIAL. The Channel is recorded at this time for later referencing.disconnected() - When the underlying channel goes inactive, the ProxyConnection moves into
ConnectionState.DISCONNECTEDbecameWritable() - When the underlying channel becomes writeable, this callback is invoked.
By default, incoming data on the underlying channel is automatically read and passed to the readProxyIncoming(Object)
method. Reading can be stopped and resumed using stopReading() and resumeReading().
| 限定符和类型 | 类和说明 |
|---|---|
protected class |
HttpProxyConnection.RequestReadMonitor
Utility handler for monitoring requests read on this connection.
|
protected class |
HttpProxyConnection.RequestWrittenMonitor
Utility handler for monitoring requests written on this connection.
|
protected class |
HttpProxyConnection.ResponseReadMonitor
Utility handler for monitoring responses read on this connection.
|
protected class |
HttpProxyConnection.ResponseWrittenMonitor
Utility handler for monitoring responses written on this connection.
|
ChannelHandler.Sharable| 限定符和类型 | 字段和说明 |
|---|---|
protected ProxyConnectionLogger |
log |
protected HttpProxyManager |
proxyManager |
channel, ctx, lastReadTime, logger, sslEngine| 限定符 | 构造器和说明 |
|---|---|
protected |
HttpProxyConnection(ConnectionState initialState,
HttpProxyManager proxyManager,
String applicationName)
Construct a new ProxyConnection.
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
becameSaturated()
Callback that's invoked if this connection becomes saturated.
|
protected void |
becameWritable()
Callback that's invoked when this connection becomes writeable again.
|
private void |
closeChannel(io.netty.util.concurrent.Promise<Void> promise) |
protected void |
connected()
This method is called as soon as the underlying
Channel is connected. |
(专用程序包) io.netty.util.concurrent.Future<Void> |
disconnect()
Disconnects.
|
protected void |
disconnected()
This method is called as soon as the underlying
Channel becomes disconnected. |
(专用程序包) void |
doWrite(Object msg) |
protected io.netty.util.concurrent.Future<Channel> |
encrypt(ChannelPipeline pipeline,
SSLEngine sslEngine)
Encrypts traffic on this connection with SSL/TLS.
|
protected io.netty.util.concurrent.Future<Channel> |
encrypt(SSLEngine sslEngine)
Encrypts traffic on this connection with SSL/TLS.
|
protected void |
exceptionCaught(Throwable cause)
Override this to handle exceptions that occurred during asynchronous processing on the
Channel. |
protected HttpFilters |
getHttpFiltersFromProxyServer(io.netty.handler.codec.http.HttpRequest httpRequest)
Request the ProxyServer for Filters.
|
(专用程序包) ProxyConnectionLogger |
getLOG() |
SSLEngine |
getSslEngine() |
protected boolean |
isSaturated()
Indicates whether or not this connection is saturated (i.e. not writeable).
|
private void |
readHTTP(io.netty.handler.codec.http.HttpObject httpObject)
Handles reading
HttpObject. |
protected abstract void |
readHTTPChunk(io.netty.handler.codec.http.HttpContent chunk)
Implement this to handle reading a chunk in a chunked transfer.
|
protected abstract ConnectionState |
readHTTPInitial(I httpObject)
Implement this to handle reading the initial object (e.g.
|
protected void |
readProxyIncoming(Object msg)
Reading
|
protected void |
resumeReading()
Call this to resume reading.
|
protected void |
stopReading()
Call this to stop reading.
|
protected void |
timedOut()
This method is called when the underlying
Channel times out due to an idle timeout. |
(专用程序包) void |
write(Object msg)
This method is called by users of the ProxyConnection to send stuff out over the socket.
|
protected void |
writeHttp(io.netty.handler.codec.http.HttpObject httpObject)
Writes HttpObjects to the connection asynchronously.
|
protected void |
writeRaw(io.netty.buffer.ByteBuf buf)
Writes raw buffers to the connection.
|
protected ChannelFuture |
writeToChannel(Object msg) |
protected ChannelFuture |
writeToChannelNoFlush(Object msg) |
become, channelActive, channelInactive, channelRead0, channelRegistered, channelRegistered0, channelWritabilityChanged, exceptionCaught, getApplicationName, getChannel, getCurrentState, is, isConnecting, readIncoming, userEventTriggeredacceptInboundMessage, channelReadchannelReadComplete, channelUnregisteredensureNotSharable, handlerAdded, handlerRemoved, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithandlerAdded, handlerRemovedprotected final ProxyConnectionLogger log
protected final HttpProxyManager proxyManager
protected HttpProxyConnection(ConnectionState initialState, HttpProxyManager proxyManager, String applicationName)
initialState - the state in which this connection starts outproxyManager - the HttpProxyManager in which we're runningapplicationName - the application name in which we're runningprotected void readProxyIncoming(Object msg)
readProxyIncoming 在类中 ProxyConnection<Object>private void readHTTP(io.netty.handler.codec.http.HttpObject httpObject)
HttpObject.httpObject - http objectprotected abstract ConnectionState readHTTPInitial(I httpObject)
HttpRequest or HttpResponse).httpObject - http objectprotected abstract void readHTTPChunk(io.netty.handler.codec.http.HttpContent chunk)
chunk - http contentvoid write(Object msg)
msg - messagevoid doWrite(Object msg)
protected void writeHttp(io.netty.handler.codec.http.HttpObject httpObject)
httpObject - http bjectprotected void writeRaw(io.netty.buffer.ByteBuf buf)
writeRaw 在类中 ProxyConnection<Object>buf - byte bufferprotected ChannelFuture writeToChannel(Object msg)
writeToChannel 在类中 ProxyConnection<Object>protected ChannelFuture writeToChannelNoFlush(Object msg)
protected void connected()
Channel is connected. Note that for proxies with complex
ConnectionFlows that include SSL handshaking and other such things, just because the Channel is
connected doesn't mean that our connection is fully established.connected 在类中 ProxyConnection<Object>protected void disconnected()
Channel becomes disconnected.disconnected 在类中 ProxyConnection<Object>protected void timedOut()
Channel times out due to an idle timeout.timedOut 在类中 ProxyConnection<Object>protected io.netty.util.concurrent.Future<Channel> encrypt(SSLEngine sslEngine)
encrypt 在类中 ProxyConnection<Object>sslEngine - the SSLEngine for doing the encryptionprotected io.netty.util.concurrent.Future<Channel> encrypt(ChannelPipeline pipeline, SSLEngine sslEngine)
encrypt 在类中 ProxyConnection<Object>pipeline - the ChannelPipeline on which to enable encryptionsslEngine - the SSLEngine for doing the encryptionprotected void becameSaturated()
becameSaturated 在类中 ProxyConnection<Object>protected void becameWritable()
becameWritable 在类中 ProxyConnection<Object>protected void exceptionCaught(Throwable cause)
Channel.exceptionCaught 在类中 ProxyConnection<Object>cause - raised errorio.netty.util.concurrent.Future<Void> disconnect()
disconnect 在类中 ProxyConnection<Object>private void closeChannel(io.netty.util.concurrent.Promise<Void> promise)
protected boolean isSaturated()
isSaturated 在类中 ProxyConnection<Object>public SSLEngine getSslEngine()
getSslEngine 在类中 ProxyConnection<Object>protected void stopReading()
stopReading 在类中 ProxyConnection<Object>protected void resumeReading()
resumeReading 在类中 ProxyConnection<Object>protected HttpFilters getHttpFiltersFromProxyServer(io.netty.handler.codec.http.HttpRequest httpRequest)
httpRequest - Filter attached to the give HttpRequest (if any)ProxyConnectionLogger getLOG()
getLOG 在类中 ProxyConnection<Object>Copyright © 2021 Zodiac. All rights reserved.