1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * 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.coyote.InputBuffer;
23 import org.apache.coyote.Request;
24 import org.apache.tomcat.util.buf.ByteChunk;
25
26 /**
27 * Input filter interface.
28 *
29 * @author Remy Maucherat
30 */
31 public interface InputFilter extends InputBuffer {
32
33 /**
34 * Some filters need additional parameters from the request.
35 *
36 * @param request The request to be associated with this filter
37 */
38 public void setRequest(Request request);
39
40
41 /**
42 * Make the filter ready to process the next request.
43 */
44 public void recycle();
45
46
47 /**
48 * Get the name of the encoding handled by this filter.
49 *
50 * @return The encoding name as a byte chunk to facilitate comparison with
51 * the value read from the HTTP headers which will also be a
52 * ByteChunk
53 */
54 public ByteChunk getEncodingName();
55
56
57 /**
58 * Set the next buffer in the filter pipeline.
59 *
60 * @param buffer The next buffer
61 */
62 public void setBuffer(InputBuffer buffer);
63
64
65 /**
66 * End the current request.
67 *
68 * @return 0 is the expected return value. A positive value indicates that
69 * too many bytes were read. This method is allowed to use buffer.doRead
70 * to consume extra bytes. The result of this method can't be negative (if
71 * an error happens, an IOException should be thrown instead).
72 *
73 * @throws IOException If an error happens
74 */
75 public long end() throws IOException;
76
77
78 /**
79 * Amount of bytes still available in a buffer.
80 *
81 * @return The number of bytes in the buffer
82 */
83 public int available();
84
85
86 /**
87 * Has the request body been read fully?
88 *
89 * @return {@code true} if the request body has been fully read, otherwise
90 * {@code false}
91 */
92 public boolean isFinished();
93 }
94