01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.coyote.http11;
19:
20: import java.io.IOException;
21:
22: import org.apache.tomcat.util.buf.ByteChunk;
23:
24: import org.apache.coyote.OutputBuffer;
25: import org.apache.coyote.Response;
26:
27: /**
28: * Output filter.
29: *
30: * @author Remy Maucherat
31: */
32: public interface OutputFilter extends OutputBuffer {
33:
34: /**
35: * Write some bytes.
36: *
37: * @return number of bytes written by the filter
38: */
39: public int doWrite(ByteChunk chunk, Response unused)
40: throws IOException;
41:
42: /**
43: * Some filters need additional parameters from the response. All the
44: * necessary reading can occur in that method, as this method is called
45: * after the response header processing is complete.
46: */
47: public void setResponse(Response response);
48:
49: /**
50: * Make the filter ready to process the next request.
51: */
52: public void recycle();
53:
54: /**
55: * Get the name of the encoding handled by this filter.
56: */
57: public ByteChunk getEncodingName();
58:
59: /**
60: * Set the next buffer in the filter pipeline.
61: */
62: public void setBuffer(OutputBuffer buffer);
63:
64: /**
65: * End the current request. It is acceptable to write extra bytes using
66: * buffer.doWrite during the execution of this method.
67: *
68: * @return Should return 0 unless the filter does some content length
69: * delimitation, in which case the number is the amount of extra bytes or
70: * missing bytes, which would indicate an error.
71: * Note: It is recommended that extra bytes be swallowed by the filter.
72: */
73: public long end() throws IOException;
74:
75: }
|