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.InputBuffer;
25: import org.apache.coyote.Request;
26:
27: /**
28: * Input filter interface.
29: *
30: * @author Remy Maucherat
31: */
32: public interface InputFilter extends InputBuffer {
33:
34: /**
35: * Read bytes.
36: *
37: * @return Number of bytes read.
38: */
39: public int doRead(ByteChunk chunk, Request unused)
40: throws IOException;
41:
42: /**
43: * Some filters need additional parameters from the request. All the
44: * necessary reading can occur in that method, as this method is called
45: * after the request header processing is complete.
46: */
47: public void setRequest(Request request);
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(InputBuffer buffer);
63:
64: /**
65: * End the current request.
66: *
67: * @return 0 is the expected return value. A positive value indicates that
68: * too many bytes were read. This method is allowed to use buffer.doRead
69: * to consume extra bytes. The result of this method can't be negative (if
70: * an error happens, an IOException should be thrown instead).
71: */
72: public long end() throws IOException;
73:
74: /**
75: * Amount of bytes still available in a buffer.
76: */
77: public int available();
78:
79: }
|