|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.jetty.servlets.ProxyServlet
public class ProxyServlet
Asynchronous Proxy Servlet. Forward requests to another server either as a standard web proxy (as defined by RFC2616) or as a transparent proxy.
This servlet needs the jetty-util and jetty-client classes to be available to the web application.
To facilitate JMX monitoring, the "HttpClient", it's "ThreadPool" and the "Logger" are set as context attributes prefixed with the servlet name.
The following init parameters may be used to configure the servlet:
ConnectHandler
Nested Class Summary | |
---|---|
static class |
ProxyServlet.Transparent
Transparent Proxy. |
Field Summary | |
---|---|
protected HostMap<PathMap> |
_black
|
protected HttpClient |
_client
|
protected ServletConfig |
_config
|
protected ServletContext |
_context
|
protected HashSet<String> |
_DontProxyHeaders
|
protected String |
_hostHeader
|
protected Logger |
_log
|
protected HostMap<PathMap> |
_white
|
Constructor Summary | |
---|---|
ProxyServlet()
|
Method Summary | |
---|---|
protected HttpClient |
createHttpClient(ServletConfig config)
Create and return an HttpClient based on ServletConfig By default this implementation will create an instance of the HttpClient for use by this proxy servlet. |
protected Logger |
createLogger(ServletConfig config)
Create and return a logger based on the ServletConfig for use in the proxy servlet |
protected void |
customizeContinuation(Continuation continuation)
Extension point for subclasses to customize the Continuation after it's initial creation in the service method. |
protected void |
customizeExchange(HttpExchange exchange,
HttpServletRequest request)
Extension point for subclasses to customize an exchange. |
void |
destroy()
|
String |
getHostHeader()
Get the hostHeader. |
ServletConfig |
getServletConfig()
|
String |
getServletInfo()
|
void |
handleConnect(HttpServletRequest request,
HttpServletResponse response)
|
protected void |
handleOnConnectionFailed(Throwable ex,
HttpServletRequest request,
HttpServletResponse response)
Extension point for custom handling of an HttpExchange's onConnectionFailed method. |
protected void |
handleOnException(Throwable ex,
HttpServletRequest request,
HttpServletResponse response)
Extension point for custom handling of an HttpExchange's onException method. |
protected void |
handleOnExpire(HttpServletRequest request,
HttpServletResponse response)
Extension point for custom handling of an HttpExchange's onExpire method. |
void |
init(ServletConfig config)
|
protected HttpURI |
proxyHttpURI(String scheme,
String serverName,
int serverPort,
String uri)
|
void |
service(ServletRequest req,
ServletResponse res)
|
void |
setHostHeader(String hostHeader)
Set the hostHeader. |
boolean |
validateDestination(String host,
String path)
Check the request hostname and path against white- and blacklist. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Logger _log
protected HttpClient _client
protected String _hostHeader
protected HashSet<String> _DontProxyHeaders
protected ServletConfig _config
protected ServletContext _context
protected HostMap<PathMap> _white
protected HostMap<PathMap> _black
Constructor Detail |
---|
public ProxyServlet()
Method Detail |
---|
public void init(ServletConfig config) throws ServletException
init
in interface Servlet
ServletException
public void destroy()
destroy
in interface Servlet
protected Logger createLogger(ServletConfig config)
config
-
protected HttpClient createHttpClient(ServletConfig config) throws Exception
config
-
Exception
public boolean validateDestination(String host, String path)
host
- hostname to checkpath
- path to check
public ServletConfig getServletConfig()
getServletConfig
in interface Servlet
public String getHostHeader()
public void setHostHeader(String hostHeader)
hostHeader
- the hostHeader to setpublic void service(ServletRequest req, ServletResponse res) throws ServletException, IOException
service
in interface Servlet
ServletException
IOException
public void handleConnect(HttpServletRequest request, HttpServletResponse response) throws IOException
IOException
protected HttpURI proxyHttpURI(String scheme, String serverName, int serverPort, String uri) throws MalformedURLException
MalformedURLException
public String getServletInfo()
getServletInfo
in interface Servlet
protected void customizeExchange(HttpExchange exchange, HttpServletRequest request)
exchange
- request
- protected void customizeContinuation(Continuation continuation)
continuation
- protected void handleOnConnectionFailed(Throwable ex, HttpServletRequest request, HttpServletResponse response)
handleOnException(Throwable, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
ex
- request
- response
- protected void handleOnException(Throwable ex, HttpServletRequest request, HttpServletResponse response)
ex
- request
- response
- protected void handleOnExpire(HttpServletRequest request, HttpServletResponse response)
request
- response
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |