public class ProxyHandler extends AbstractHttpHandler
Modifier and Type | Class and Description |
---|---|
static class |
ProxyHandler.SslRelay |
Modifier and Type | Field and Description |
---|---|
protected HashSet<Integer> |
_allowedConnectPorts
Set of allowed CONNECT ports.
|
protected StringMap |
_DontProxyHeaders
Map of leg by leg headers (not end to end).
|
protected StringMap |
_ProxyAuthHeaders
Map of leg by leg headers (not end to end).
|
protected Set<String> |
_proxyHostsBlackList |
protected Set<String> |
_proxyHostsWhiteList |
protected StringMap |
_ProxySchemes
Map of allows schemes to proxy Should be a set, but more efficient string map is used instead.
|
protected int |
_tunnelTimeoutMs |
Constructor and Description |
---|
ProxyHandler(boolean trustAllSSLCertificates,
String dontInjectRegex,
String debugURL,
boolean proxyInjectionMode,
boolean forceProxyChain,
int port,
Object shutdownLock) |
Modifier and Type | Method and Description |
---|---|
void |
generateSSLCertsForLoggingHosts(HttpServer server) |
protected ProxyHandler.SslRelay |
getSslRelayOrCreateNew(URI uri,
String serverHost,
Integer serverPort,
HttpServer server) |
void |
handle(String pathInContext,
String pathParams,
HttpRequest request,
HttpResponse response)
Handle a request.
|
void |
handleConnect(HttpRequest request,
HttpResponse response) |
protected boolean |
isForbidden(String scheme,
String host)
Is scheme,host & port Forbidden.
|
protected boolean |
isForbidden(URI uri)
Is URL Forbidden.
|
protected URL |
isProxied(URI uri)
Is URL Proxied.
|
protected HttpTunnel |
newHttpTunnel(HttpResponse response,
InetAddress iaddr,
int port,
int timeoutMS) |
protected long |
proxyPlainTextRequest(URL url,
HttpRequest request,
HttpResponse response) |
protected void |
sendForbid(HttpResponse response)
Send Forbidden.
|
protected void |
sendNotFound(HttpResponse response)
Send not found.
|
boolean |
shouldInject(String path) |
void |
start()
Start the LifeCycle.
|
protected void |
wireUpSslWithCyberVilliansCA(String host,
ProxyHandler.SslRelay listener) |
getHttpContext, getName, handleTrace, initialize, isStarted, setName, stop, toString
protected int _tunnelTimeoutMs
protected StringMap _DontProxyHeaders
protected StringMap _ProxyAuthHeaders
protected StringMap _ProxySchemes
public void start() throws Exception
LifeCycle
start
in interface LifeCycle
start
in class AbstractHttpHandler
Exception
- An arbitrary exception may be thrown.public void handle(String pathInContext, String pathParams, HttpRequest request, HttpResponse response) throws IOException
HttpHandler
pathInContext
- The context pathpathParams
- Path parameters such as encoded Session IDrequest
- The HttpRequest requestresponse
- The HttpResponse responseIOException
protected long proxyPlainTextRequest(URL url, HttpRequest request, HttpResponse response) throws IOException
IOException
public boolean shouldInject(String path)
public void generateSSLCertsForLoggingHosts(HttpServer server)
public void handleConnect(HttpRequest request, HttpResponse response) throws IOException
IOException
protected ProxyHandler.SslRelay getSslRelayOrCreateNew(URI uri, String serverHost, Integer serverPort, HttpServer server) throws Exception
Exception
protected void wireUpSslWithCyberVilliansCA(String host, ProxyHandler.SslRelay listener)
protected HttpTunnel newHttpTunnel(HttpResponse response, InetAddress iaddr, int port, int timeoutMS) throws IOException
IOException
protected URL isProxied(URI uri) throws MalformedURLException
uri
- The requested URI, which should include a scheme, host and port.MalformedURLException
protected boolean isForbidden(URI uri)
protected boolean isForbidden(String scheme, String host)
scheme
- A scheme that mast be in the proxySchemes StringMap.host
- A host that must pass the white and black listsprotected void sendForbid(HttpResponse response) throws IOException
IOException
protected void sendNotFound(HttpResponse response) throws IOException
IOException
Copyright © 2013. All rights reserved.