|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectorg.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" and "ThreadPool" are set as context attributes prefixed with the servlet name.
The following init parameters may be used to configure the servlet:
ConnectHandler| 嵌套类摘要 | |
|---|---|
static class |
ProxyServlet.Transparent
Transparent Proxy. |
| 字段摘要 | |
|---|---|
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
|
| 构造方法摘要 | |
|---|---|
ProxyServlet()
|
|
| 方法摘要 | |
|---|---|
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 HttpClient |
createHttpClientInstance()
Create and return an HttpClientInstance |
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()
Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. |
protected String |
filterResponseHeaderValue(String headerName,
String headerValue,
HttpServletRequest request)
Extension point for remote server response header filtering. |
String |
getHostHeader()
Get the hostHeader. |
ServletConfig |
getServletConfig()
Returns a ServletConfig object, which contains
initialization and startup parameters for this servlet. |
String |
getServletInfo()
Returns information about the servlet, such as author, version, and copyright. |
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)
Called by the servlet container to indicate to a servlet that the servlet is being placed into service. |
protected HttpURI |
proxyHttpURI(HttpServletRequest request,
String uri)
|
protected HttpURI |
proxyHttpURI(String scheme,
String serverName,
int serverPort,
String uri)
|
void |
service(ServletRequest req,
ServletResponse res)
Called by the servlet container to allow the servlet to respond to a request. |
void |
setHostHeader(String hostHeader)
Set the hostHeader. |
boolean |
validateDestination(String host,
String path)
Check the request hostname and path against white- and blacklist. |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 字段详细信息 |
|---|
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
| 构造方法详细信息 |
|---|
public ProxyServlet()
| 方法详细信息 |
|---|
public void init(ServletConfig config)
throws ServletException
Servlet 复制的描述The servlet container calls the init
method exactly once after instantiating the servlet.
The init method must complete successfully
before the servlet can receive any requests.
The servlet container cannot place the servlet into service
if the init method
ServletException
Servlet 中的 initconfig - a ServletConfig object
containing the servlet's
configuration and initialization parameters
ServletException - if an exception has occurred that
interferes with the servlet's normal
operationUnavailableException,
Servlet.getServletConfig()public void destroy()
Servlet 复制的描述service method have exited or after a timeout
period has passed. After the servlet container calls this
method, it will not call the service method again
on this servlet.
This method gives the servlet an opportunity to clean up any resources that are being held (for example, memory, file handles, threads) and make sure that any persistent state is synchronized with the servlet's current state in memory.
Servlet 中的 destroyprotected Logger createLogger(ServletConfig config)
config -
protected HttpClient createHttpClientInstance()
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()
Servlet 复制的描述ServletConfig object, which contains
initialization and startup parameters for this servlet.
The ServletConfig object returned is the one
passed to the init method.
Implementations of this interface are responsible for storing the
ServletConfig object so that this
method can return it. The GenericServlet
class, which implements this interface, already does this.
Servlet 中的 getServletConfigServletConfig object
that initializes this servletServlet.init(javax.servlet.ServletConfig)public String getHostHeader()
public void setHostHeader(String hostHeader)
hostHeader - the hostHeader to set
public void service(ServletRequest req,
ServletResponse res)
throws ServletException,
IOException
Servlet 复制的描述This method is only called after the servlet's init()
method has completed successfully.
The status code of the response always should be set for a servlet that throws or sends an error.
Servlets typically run inside multithreaded servlet containers that can handle multiple requests concurrently. Developers must be aware to synchronize access to any shared resources such as files, network connections, and as well as the servlet's class and instance variables. More information on multithreaded programming in Java is available in the Java tutorial on multi-threaded programming.
Servlet 中的 servicereq - the ServletRequest object that contains
the client's requestres - the ServletResponse object that contains
the servlet's response
ServletException - if an exception occurs that interferes
with the servlet's normal operation
IOException - if an input or output exception occurs
public void handleConnect(HttpServletRequest request,
HttpServletResponse response)
throws IOException
IOException
protected HttpURI proxyHttpURI(HttpServletRequest request,
String uri)
throws MalformedURLException
MalformedURLException
protected HttpURI proxyHttpURI(String scheme,
String serverName,
int serverPort,
String uri)
throws MalformedURLException
MalformedURLExceptionpublic String getServletInfo()
Servlet 复制的描述The string that this method returns should be plain text and not markup of any kind (such as HTML, XML, etc.).
Servlet 中的 getServletInfoString containing servlet information
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 -
protected String filterResponseHeaderValue(String headerName,
String headerValue,
HttpServletRequest request)
headerName - headerValue - request -
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||