com.mortbay.HTTP
Class HttpFilter
java.lang.Object
|
+--java.io.OutputStream
|
+--java.io.FilterOutputStream
|
+--com.mortbay.HTTP.HttpFilter
- Direct Known Subclasses:
- GzipFilter, HtmlFilter
- public class HttpFilter
- extends java.io.FilterOutputStream
- implements java.util.Observer
Http Filter
Derived Http Filters may be added into HttpOutputStreams.
A HttpOutputStream
will check the content types handled by a filter and if pass all
output through the filter if it can handle the type of the HTTP response.
The FilterHandler HttpHandler can be used to insert HttpFilters
into HttpResponses.
ActivateOn is called after any HTTP/1.1 chunked output is added
to the HttpOutputStream, so filters always receive pre-chunked data.
- Version:
- $Id: HttpFilter.java,v 2.6 2000/06/02 23:41:05 gregw Exp $
- Author:
- Greg Wilkins
Fields inherited from class java.io.FilterOutputStream |
out |
Method Summary |
protected void |
activate()
Notify derived class of activation |
void |
activateOn(HttpResponse response)
Activate a filter on a response. |
protected boolean |
canHandle(java.lang.String contentType)
Check for handling of content type. |
void |
test(java.io.OutputStream out)
Set output stream for testing purposes. |
void |
update(java.util.Observable o,
java.lang.Object arg)
Observer update. |
Methods inherited from class java.io.FilterOutputStream |
close,
flush,
write,
write,
write |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
request
protected HttpRequest request
response
protected HttpResponse response
HttpFilter
public HttpFilter()
HttpFilter
public HttpFilter(HttpRequest request)
canHandle
protected boolean canHandle(java.lang.String contentType)
- Check for handling of content type.
This method must be implemented by the derived class to indicate
the content types handled by the filter. The default implementation
returns true for text content types.
Called by activate.
activateOn
public final void activateOn(HttpResponse response)
throws java.io.IOException
- Activate a filter on a response.
Activate is called on a filter by a HttpResponse, normally just
before the response headers are written. If canHandle() returns
true, the filter is inserted into the HttpResponse output stream and
a thread started to run the filter.
test
public void test(java.io.OutputStream out)
- Set output stream for testing purposes.
- Parameters:
out
- OutputStream
activate
protected void activate()
- Notify derived class of activation
update
public void update(java.util.Observable o,
java.lang.Object arg)
- Observer update.
This method is called as part of the Observer pattern to notify
the filter that headers are about to be written. The call is
delegated to activateOn(HttpResponse).
- Specified by:
- update in interface java.util.Observer
- Parameters:
o
- ignoredarg
- The HttpResponse.