View Javadoc

1   /*
2    * Copyright 2012 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package org.jboss.netty.handler.codec.http.multipart;
17  
18  import java.util.List;
19  
20  import org.jboss.netty.handler.codec.http.HttpChunk;
21  import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.EndOfDataDecoderException;
22  import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException;
23  import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.NotEnoughDataDecoderException;
24  
25  public interface InterfaceHttpPostRequestDecoder {
26      /**
27       * True if this request is a Multipart request
28       * @return True if this request is a Multipart request
29       */
30      boolean isMultipart();
31  
32      /**
33       * This method returns a List of all HttpDatas from body.<br>
34       *
35       * If chunked, all chunks must have been offered using offer() method.
36       * If not, NotEnoughDataDecoderException will be raised.
37       *
38       * @return the list of HttpDatas from Body part for POST method
39       * @throws NotEnoughDataDecoderException Need more chunks
40       */
41      List<InterfaceHttpData> getBodyHttpDatas()
42              throws NotEnoughDataDecoderException;
43  
44      /**
45       * This method returns a List of all HttpDatas with the given name from body.<br>
46       *
47       * If chunked, all chunks must have been offered using offer() method.
48       * If not, NotEnoughDataDecoderException will be raised.
49  
50       * @return All Body HttpDatas with the given name (ignore case)
51       * @throws NotEnoughDataDecoderException need more chunks
52       */
53      List<InterfaceHttpData> getBodyHttpDatas(String name)
54              throws NotEnoughDataDecoderException;
55  
56      /**
57       * This method returns the first InterfaceHttpData with the given name from body.<br>
58       *
59       * If chunked, all chunks must have been offered using offer() method.
60       * If not, NotEnoughDataDecoderException will be raised.
61      *
62      * @return The first Body InterfaceHttpData with the given name (ignore case)
63      * @throws NotEnoughDataDecoderException need more chunks
64      */
65      InterfaceHttpData getBodyHttpData(String name)
66              throws NotEnoughDataDecoderException;
67  
68      /**
69       * Initialized the internals from a new chunk
70       * @param chunk the new received chunk
71       * @throws ErrorDataDecoderException if there is a problem with the charset decoding or
72       *          other errors
73       */
74      void offer(HttpChunk chunk) throws ErrorDataDecoderException;
75  
76      /**
77       * True if at current status, there is an available decoded InterfaceHttpData from the Body.
78       *
79       * This method works for chunked and not chunked request.
80       *
81       * @return True if at current status, there is a decoded InterfaceHttpData
82       * @throws EndOfDataDecoderException No more data will be available
83       */
84      boolean hasNext() throws EndOfDataDecoderException;
85  
86      /**
87       * Returns the next available InterfaceHttpData or null if, at the time it is called, there is no more
88       * available InterfaceHttpData. A subsequent call to offer(httpChunk) could enable more data.
89       *
90       * @return the next available InterfaceHttpData or null if none
91       * @throws EndOfDataDecoderException No more data will be available
92       */
93      InterfaceHttpData next() throws EndOfDataDecoderException;
94  
95      /**
96       * Clean all HttpDatas (on Disk) for the current request.
97       */
98      void cleanFiles();
99  
100     /**
101      * Remove the given FileUpload from the list of FileUploads to clean
102      */
103     void removeHttpDataFromClean(InterfaceHttpData data);
104 
105 }