01: /*
02: * Copyright 1999-2004 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.coyote.http11;
18:
19: import java.io.IOException;
20:
21: import org.apache.tomcat.util.buf.ByteChunk;
22:
23: import org.apache.coyote.InputBuffer;
24: import org.apache.coyote.Request;
25:
26: /**
27: * Input filter interface.
28: *
29: * @author Remy Maucherat
30: */
31: public interface InputFilter extends InputBuffer {
32:
33: /**
34: * Read bytes.
35: *
36: * @return Number of bytes read.
37: */
38: public int doRead(ByteChunk chunk, Request unused)
39: throws IOException;
40:
41: /**
42: * Some filters need additional parameters from the request. All the
43: * necessary reading can occur in that method, as this method is called
44: * after the request header processing is complete.
45: */
46: public void setRequest(Request request);
47:
48: /**
49: * Make the filter ready to process the next request.
50: */
51: public void recycle();
52:
53: /**
54: * Get the name of the encoding handled by this filter.
55: */
56: public ByteChunk getEncodingName();
57:
58: /**
59: * Set the next buffer in the filter pipeline.
60: */
61: public void setBuffer(InputBuffer buffer);
62:
63: /**
64: * End the current request.
65: *
66: * @return 0 is the expected return value. A positive value indicates that
67: * too many bytes were read. This method is allowed to use buffer.doRead
68: * to consume extra bytes. The result of this method can't be negative (if
69: * an error happens, an IOException should be thrown instead).
70: */
71: public long end() throws IOException;
72:
73: }
|