|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openqa.jetty.http.handler.AbstractHttpHandler
org.openqa.jetty.http.handler.ProxyHandler
public class ProxyHandler
Proxy request handler. A HTTP/1.1 Proxy. This implementation uses the JVMs URL implementation to make proxy requests.
The HttpTunnel mechanism is also used to implement the CONNECT method.
Field Summary | |
---|---|
protected java.util.HashSet |
_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 java.util.Set |
_proxyHostsBlackList
|
protected java.util.Set |
_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 Summary | |
---|---|
ProxyHandler()
|
Method Summary | |
---|---|
protected void |
customizeConnection(java.lang.String pathInContext,
java.lang.String pathParams,
HttpRequest request,
java.net.Socket socket)
Customize proxy Socket connection for CONNECT. |
protected void |
customizeConnection(java.lang.String pathInContext,
java.lang.String pathParams,
HttpRequest request,
java.net.URLConnection connection)
Customize proxy URL connection. |
java.lang.String[] |
getProxyHostsBlackList()
Get proxy host black list. |
java.lang.String[] |
getProxyHostsWhiteList()
Get proxy host white list. |
int |
getTunnelTimeoutMs()
|
void |
handle(java.lang.String pathInContext,
java.lang.String pathParams,
HttpRequest request,
HttpResponse response)
Handle a request. |
void |
handleConnect(java.lang.String pathInContext,
java.lang.String pathParams,
HttpRequest request,
HttpResponse response)
|
boolean |
isAnonymous()
|
protected boolean |
isForbidden(java.lang.String scheme,
java.lang.String host,
int port,
boolean openNonPrivPorts)
Is scheme,host & port Forbidden. |
protected boolean |
isForbidden(URI uri)
Is URL Forbidden. |
protected java.net.URL |
isProxied(URI uri)
Is URL Proxied. |
protected HttpTunnel |
newHttpTunnel(HttpRequest request,
HttpResponse response,
java.net.InetAddress iaddr,
int port,
int timeoutMS)
|
protected void |
sendForbid(HttpRequest request,
HttpResponse response,
URI uri)
Send Forbidden. |
void |
setAnonymous(boolean anonymous)
|
void |
setProxyHostsBlackList(java.lang.String[] hosts)
Set proxy host black list. |
void |
setProxyHostsWhiteList(java.lang.String[] hosts)
Set proxy host white list. |
void |
setTunnelTimeoutMs(int ms)
Tunnel timeout. |
void |
start()
Start the LifeCycle. |
Methods inherited from class org.openqa.jetty.http.handler.AbstractHttpHandler |
---|
getHttpContext, getName, handleTrace, initialize, isStarted, setName, stop, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.util.Set _proxyHostsWhiteList
protected java.util.Set _proxyHostsBlackList
protected int _tunnelTimeoutMs
protected StringMap _DontProxyHeaders
protected StringMap _ProxyAuthHeaders
protected StringMap _ProxySchemes
protected java.util.HashSet _allowedConnectPorts
Constructor Detail |
---|
public ProxyHandler()
Method Detail |
---|
public void start() throws java.lang.Exception
LifeCycle
start
in interface LifeCycle
start
in class AbstractHttpHandler
java.lang.Exception
- An arbitrary exception may be thrown.public java.lang.String[] getProxyHostsWhiteList()
public void setProxyHostsWhiteList(java.lang.String[] hosts)
hosts
- Array of hostnames and IPs that are proxied, or null if all hosts are proxied.public java.lang.String[] getProxyHostsBlackList()
public void setProxyHostsBlackList(java.lang.String[] hosts)
hosts
- Array of hostnames and IPs that are NOT proxied.public int getTunnelTimeoutMs()
public void setTunnelTimeoutMs(int ms)
public void handle(java.lang.String pathInContext, java.lang.String pathParams, HttpRequest request, HttpResponse response) throws HttpException, java.io.IOException
HttpHandler
pathInContext
- The context pathpathParams
- Path parameters such as encoded Session IDrequest
- The HttpRequest requestresponse
- The HttpResponse response
HttpException
java.io.IOException
public void handleConnect(java.lang.String pathInContext, java.lang.String pathParams, HttpRequest request, HttpResponse response) throws HttpException, java.io.IOException
HttpException
java.io.IOException
protected HttpTunnel newHttpTunnel(HttpRequest request, HttpResponse response, java.net.InetAddress iaddr, int port, int timeoutMS) throws java.io.IOException
java.io.IOException
protected void customizeConnection(java.lang.String pathInContext, java.lang.String pathParams, HttpRequest request, java.net.Socket socket) throws java.io.IOException
java.io.IOException
protected void customizeConnection(java.lang.String pathInContext, java.lang.String pathParams, HttpRequest request, java.net.URLConnection connection) throws java.io.IOException
java.io.IOException
protected java.net.URL isProxied(URI uri) throws java.net.MalformedURLException
uri
- The requested URI, which should include a scheme, host and port.
java.net.MalformedURLException
protected boolean isForbidden(URI uri)
protected boolean isForbidden(java.lang.String scheme, java.lang.String host, int port, boolean openNonPrivPorts)
scheme
- A scheme that mast be in the proxySchemes StringMap.host
- A host that must pass the white and black listsport
- A port that must in the allowedConnectPorts SetopenNonPrivPorts
- If true ports greater than 1024 are allowed.
protected void sendForbid(HttpRequest request, HttpResponse response, URI uri) throws java.io.IOException
java.io.IOException
public boolean isAnonymous()
public void setAnonymous(boolean anonymous)
anonymous
- The anonymous to set.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |