public final class HTTPProxyTCPProxyEngine extends AbstractTCPProxyEngine
A HTTPS proxy client first send a CONNECT message to the proxy port. The proxy accepts the connection responds with a 200 OK, which is the client's queue to send SSL data to the proxy. The proxy just forwards it on to the server identified by the CONNECT message.
The Java API presents a particular challenge: it allows sockets to be either SSL or not SSL, but doesn't let them change their stripes midstream. (In fact, if the JSSE support was stream oriented rather than socket oriented, a lot of problems would go away). To hack around this, we accept the CONNECT then blindly proxy the rest of the stream through a special delegate TCPProxyEngineImplementation which instantiated to handle SSL.
AbstractTCPProxyEngine.FilteredStreamThread, AbstractTCPProxyEngine.OutputStreamFilterTee, AbstractTCPProxyEngine.StreamThread
Constructor and Description |
---|
HTTPProxyTCPProxyEngine(TCPProxySSLSocketFactory sslSocketFactory,
TCPProxyFilter requestFilter,
TCPProxyFilter responseFilter,
PrintWriter output,
org.slf4j.Logger logger,
EndPoint localEndPoint,
boolean useColour,
int timeout,
EndPoint chainedHTTPProxy,
EndPoint chainedHTTPSProxy)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
run()
Main event loop.
|
void |
stop()
Override to also stop our delegate SSL engine.
|
accept, getListenEndPoint, getLogger, getRequestColour, getRequestFilter, getResponseColour, getResponseFilter, getSocketFactory, isStopped, launchThreadPair, logIOException
public HTTPProxyTCPProxyEngine(TCPProxySSLSocketFactory sslSocketFactory, TCPProxyFilter requestFilter, TCPProxyFilter responseFilter, PrintWriter output, org.slf4j.Logger logger, EndPoint localEndPoint, boolean useColour, int timeout, EndPoint chainedHTTPProxy, EndPoint chainedHTTPSProxy) throws IOException, PatternSyntaxException
sslSocketFactory
- Factory for SSL sockets.requestFilter
- Request filter.responseFilter
- Response filter.output
- Output stream.logger
- Logger.localEndPoint
- Local host and port.useColour
- Whether to use colour.timeout
- Timeout for server socket in milliseconds.chainedHTTPProxy
- HTTP proxy which output should be routed
through, or null
for no proxy.chainedHTTPSProxy
- HTTP proxy which output should be routed
through, or null
for no proxy.IOException
- If an I/O error occursPatternSyntaxException
- If a regular expression
error occurs.public void run()
run
in interface Runnable
run
in class AbstractTCPProxyEngine
public void stop()
stop
in interface TCPProxyEngine
stop
in class AbstractTCPProxyEngine
Copyright © 2000-2014. All Rights Reserved.