View Javadoc
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  package org.apache.commons.fileupload2.core;
18  
19  import java.util.Iterator;
20  
21  /**
22   * This class provides support for accessing the headers for a file or form item that was received within a {@code multipart/form-data} POST request.
23   */
24  public interface FileItemHeaders {
25  
26      /**
27       * Adds a header.
28       *
29       * @param name  name
30       * @param value value.
31       */
32      void addHeader(String name, String value);
33  
34      /**
35       * Gets the value of the specified part header as a {@code String}.
36       * <p>
37       * If the part did not include a header of the specified name, this method return {@code null}. If there are multiple headers with the same name, this
38       * method returns the first header in the item. The header name is case insensitive.
39       * </p>
40       *
41       * @param name a {@code String} specifying the header name
42       * @return a {@code String} containing the value of the requested header, or {@code null} if the item does not have a header of that name
43       */
44      String getHeader(String name);
45  
46      /**
47       * Gets an {@code Iterator} of all the header names.
48       *
49       * @return an {@code Iterator} containing all of the names of headers provided with this file item. If the item does not have any headers return an empty
50       *         {@code Iterator}
51       */
52      Iterator<String> getHeaderNames();
53  
54      /**
55       * Gets all the values of the specified item header as an {@code Iterator} of {@code String} objects.
56       * <p>
57       * If the item did not include any headers of the specified name, this method returns an empty {@code Iterator}. The header name is case insensitive.
58       * </p>
59       *
60       * @param name a {@code String} specifying the header name
61       * @return an {@code Iterator} containing the values of the requested header. If the item does not have any headers of that name, return an empty
62       *         {@code Iterator}
63       */
64      Iterator<String> getHeaders(String name);
65  
66  }