|
Femto Web Server V1.4-F | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--dfischer.femtowebserver.httpd.HttpdFilter
A HttpdFilter is an object that allows filtering tasks on either the HTTP request to a resource (a Weblet or static content), or on the HTTP response from a resource, or both.
For every HTTP request, a new instance of the HttpdFilter class will be created and the method filterRequest() will be called before the request will be processes by the Femto Web Server itself. After processing the request, the method filterResponse() will be called before the final output will be transferred to the agent (browser).
An optional capability of a HttpdFilter is to abort the request or the response by calling the method abortRequest(). In such a case a reference to a new (blank) HttpResponse will be given back to the HttpdFilter and the filter itself can override the whole HTTP response from the Femto Web Server by its own new response. If abortRequest() is already called during filterRequest(), the Femto Web Server will not process the originally browser request. The method abortRequest() will break/interrupt all chained filters - the filtering will stop immediately.
That a filter becomes active, it must first be added by calling the method Httpd.addFilter() on the Femto Web Server instance. It's also possible to chain filters by adding more than one. Such chained filters are called in the order where they have been added. The method addFilter() can optionally pass filter configuration parameters to the filter, called filter arguments.
A special feature is also, that filters can be added or removed at runtime whitout stopping the Femto Web Server.
Programming Hint 1: declaring local, non static variables and references at class level allows to transfer internal filter data from the filterRequest() to the filterResponse(). These variables and references have only the same value for a single request/response pair.
Programming Hint 2: please have a look on the already implemented filters
ContentCompressionFilter,
RestrictedInetAddressFilter,
HttpDebugFilter and
HttpSessionCookieHandler.
The source code and a configuration example is included in the java doc.
Httpd.addFilter(String),
Httpd.addFilter(String, String[]),
Httpd.removeFilter(java.lang.String),
Httpd.getFilterClassNames(),
Httpd.getFilterArguments(java.lang.String)| Method Summary | |
HttpResponse |
abortRequest()
Aborts the current HTTP request or response and overrides the ordinary HTTP response. |
abstract void |
filterRequest(HttpRequest httpRequest,
HttpResponse httpResponse)
Allows filtering tasks on the HTTP request and to preset the HTTP response (at his time blank). |
abstract void |
filterResponse(HttpRequest httpRequest,
HttpResponse httpResponse)
Allows filtering tasks on the HTTP response and to access the HTTP request. |
java.lang.String[] |
getFilterArguments()
Returns the (optionally) filter arguments. |
HttpdProperties |
getHttpdProperties()
Returns the Femto Web Server configuration |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public java.lang.String[] getFilterArguments()
Httpd.addFilter(String, String[])public HttpdProperties getHttpdProperties()
HttpdProperties.getSessionHashtable()
public abstract void filterRequest(HttpRequest httpRequest,
HttpResponse httpResponse)
throws java.lang.Exception
httpRequest - The HTTP request data (browser request)HttpResponse - The HTTP response data (server response)HttpRequest.getSession(),
HttpRequest.setSession(dfischer.femtowebserver.httpd.HttpdSession),
HttpRequest.getRemoteAddress(),
HttpRequest.setRemoteAddress(java.lang.String),
HttpRequest.getVirtualHost(),
HttpRequest.setVirtualHost(java.lang.String),
HttpRequest.getVirtualPort(),
HttpRequest.setVirtualPort(int),
HttpRequest.getUserAgent(),
HttpRequest.setUserAgent(java.lang.String),
HttpRequest.getHeaderField(java.lang.String),
HttpRequest.addHeaderField(java.lang.String, java.lang.String),
HttpRequest.updateHeaderField(java.lang.String, java.lang.String),
HttpRequest.removeHeaderField(java.lang.String),
HttpRequest.getMethod(),
HttpRequest.setMethod(java.lang.String),
HttpRequest.getRequest(),
HttpRequest.setRequest(java.lang.String),
HttpRequest.getParameter(String),
HttpRequest.addParameter(java.lang.String, java.lang.String),
HttpRequest.updateParameter(java.lang.String, java.lang.String),
HttpRequest.removeParameter(java.lang.String),
HttpRequest.getContent(),
HttpRequest.setContent(byte[]),
HttpRequest.clearContent(),
HttpRequest.getContentType(),
HttpRequest.setContentType(java.lang.String),
HttpRequest.getContentSubtype(),
HttpRequest.setContentSubtype(java.lang.String)
public abstract void filterResponse(HttpRequest httpRequest,
HttpResponse httpResponse)
throws java.lang.Exception
httpRequest - The HTTP request data (browser request)HttpResponse - The HTTP response data (server response)HttpResponse.getSession(),
HttpResponse.setSession(dfischer.femtowebserver.httpd.HttpdSession),
HttpResponse.getStatus(),
HttpResponse.setStatus(int, java.lang.String),
HttpResponse.getContentType(),
HttpResponse.getContentSubtype(),
HttpResponse.setContentType(java.lang.String),
HttpResponse.getHeaderField(java.lang.String),
HttpResponse.getHeaderFieldNames(),
HttpResponse.updateHeaderField(java.lang.String, java.lang.String),
HttpResponse.addHeaderField(java.lang.String, java.lang.String),
HttpResponse.removeHeaderField(java.lang.String),
HttpResponse.getContent(),
HttpResponse.getContentAsString(),
HttpResponse.setContent(byte[]),
HttpResponse.clearContent(),
HttpResponse.print(String),
HttpResponse.println(String)
public HttpResponse abortRequest()
throws java.io.IOException
|
Femto Web Server V1.4-F | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||