001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.fileupload2.core;
018
019import java.util.Iterator;
020
021/**
022 * 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.
023 */
024public interface FileItemHeaders {
025
026    /**
027     * Adds a header.
028     *
029     * @param name  name
030     * @param value value.
031     */
032    void addHeader(String name, String value);
033
034    /**
035     * Gets the value of the specified part header as a {@code String}.
036     * <p>
037     * 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
038     * method returns the first header in the item. The header name is case insensitive.
039     * </p>
040     *
041     * @param name a {@code String} specifying the header name
042     * @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
043     */
044    String getHeader(String name);
045
046    /**
047     * Gets an {@code Iterator} of all the header names.
048     *
049     * @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
050     *         {@code Iterator}
051     */
052    Iterator<String> getHeaderNames();
053
054    /**
055     * Gets all the values of the specified item header as an {@code Iterator} of {@code String} objects.
056     * <p>
057     * 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.
058     * </p>
059     *
060     * @param name a {@code String} specifying the header name
061     * @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
062     *         {@code Iterator}
063     */
064    Iterator<String> getHeaders(String name);
065
066}