michael@0: /*
michael@0: * ====================================================================
michael@0: * Licensed to the Apache Software Foundation (ASF) under one
michael@0: * or more contributor license agreements. See the NOTICE file
michael@0: * distributed with this work for additional information
michael@0: * regarding copyright ownership. The ASF licenses this file
michael@0: * to you under the Apache License, Version 2.0 (the
michael@0: * "License"); you may not use this file except in compliance
michael@0: * with the License. You may obtain a copy of the License at
michael@0: *
michael@0: * http://www.apache.org/licenses/LICENSE-2.0
michael@0: *
michael@0: * Unless required by applicable law or agreed to in writing,
michael@0: * software distributed under the License is distributed on an
michael@0: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
michael@0: * KIND, either express or implied. See the License for the
michael@0: * specific language governing permissions and limitations
michael@0: * under the License.
michael@0: * ====================================================================
michael@0: *
michael@0: * This software consists of voluntary contributions made by many
michael@0: * individuals on behalf of the Apache Software Foundation. For more
michael@0: * information on the Apache Software Foundation, please see
michael@0: *
michael@0: * HTTP-message = Request | Response ; HTTP/1.1 messages michael@0: *michael@0: *
michael@0: * HTTP messages use the generic message format of RFC 822 for michael@0: * transferring entities (the payload of the message). Both types michael@0: * of message consist of a start-line, zero or more header fields michael@0: * (also known as "headers"), an empty line (i.e., a line with nothing michael@0: * preceding the CRLF) indicating the end of the header fields, michael@0: * and possibly a message-body. michael@0: *
michael@0: *michael@0: * generic-message = start-line michael@0: * *(message-header CRLF) michael@0: * CRLF michael@0: * [ message-body ] michael@0: * start-line = Request-Line | Status-Line michael@0: *michael@0: * michael@0: * @since 4.0 michael@0: */ michael@0: public interface HttpMessage { michael@0: michael@0: /** michael@0: * Returns the protocol version this message is compatible with. michael@0: */ michael@0: ProtocolVersion getProtocolVersion(); michael@0: michael@0: /** michael@0: * Checks if a certain header is present in this message. Header values are michael@0: * ignored. michael@0: * michael@0: * @param name the header name to check for. michael@0: * @return true if at least one header with this name is present. michael@0: */ michael@0: boolean containsHeader(String name); michael@0: michael@0: /** michael@0: * Returns all the headers with a specified name of this message. Header values michael@0: * are ignored. Headers are orderd in the sequence they will be sent over a michael@0: * connection. michael@0: * michael@0: * @param name the name of the headers to return. michael@0: * @return the headers whose name property equals
name
.
michael@0: */
michael@0: Header[] getHeaders(String name);
michael@0:
michael@0: /**
michael@0: * Returns the first header with a specified name of this message. Header
michael@0: * values are ignored. If there is more than one matching header in the
michael@0: * message the first element of {@link #getHeaders(String)} is returned.
michael@0: * If there is no matching header in the message null
is
michael@0: * returned.
michael@0: *
michael@0: * @param name the name of the header to return.
michael@0: * @return the first header whose name property equals name
michael@0: * or null
if no such header could be found.
michael@0: */
michael@0: Header getFirstHeader(String name);
michael@0:
michael@0: /**
michael@0: * Returns the last header with a specified name of this message. Header values
michael@0: * are ignored. If there is more than one matching header in the message the
michael@0: * last element of {@link #getHeaders(String)} is returned. If there is no
michael@0: * matching header in the message null
is returned.
michael@0: *
michael@0: * @param name the name of the header to return.
michael@0: * @return the last header whose name property equals name
.
michael@0: * or null
if no such header could be found.
michael@0: */
michael@0: Header getLastHeader(String name);
michael@0:
michael@0: /**
michael@0: * Returns all the headers of this message. Headers are orderd in the sequence
michael@0: * they will be sent over a connection.
michael@0: *
michael@0: * @return all the headers of this message
michael@0: */
michael@0: Header[] getAllHeaders();
michael@0:
michael@0: /**
michael@0: * Adds a header to this message. The header will be appended to the end of
michael@0: * the list.
michael@0: *
michael@0: * @param header the header to append.
michael@0: */
michael@0: void addHeader(Header header);
michael@0:
michael@0: /**
michael@0: * Adds a header to this message. The header will be appended to the end of
michael@0: * the list.
michael@0: *
michael@0: * @param name the name of the header.
michael@0: * @param value the value of the header.
michael@0: */
michael@0: void addHeader(String name, String value);
michael@0:
michael@0: /**
michael@0: * Overwrites the first header with the same name. The new header will be appended to
michael@0: * the end of the list, if no header with the given name can be found.
michael@0: *
michael@0: * @param header the header to set.
michael@0: */
michael@0: void setHeader(Header header);
michael@0:
michael@0: /**
michael@0: * Overwrites the first header with the same name. The new header will be appended to
michael@0: * the end of the list, if no header with the given name can be found.
michael@0: *
michael@0: * @param name the name of the header.
michael@0: * @param value the value of the header.
michael@0: */
michael@0: void setHeader(String name, String value);
michael@0:
michael@0: /**
michael@0: * Overwrites all the headers in the message.
michael@0: *
michael@0: * @param headers the array of headers to set.
michael@0: */
michael@0: void setHeaders(Header[] headers);
michael@0:
michael@0: /**
michael@0: * Removes a header from this message.
michael@0: *
michael@0: * @param header the header to remove.
michael@0: */
michael@0: void removeHeader(Header header);
michael@0:
michael@0: /**
michael@0: * Removes all headers with a certain name from this message.
michael@0: *
michael@0: * @param name The name of the headers to remove.
michael@0: */
michael@0: void removeHeaders(String name);
michael@0:
michael@0: /**
michael@0: * Returns an iterator of all the headers.
michael@0: *
michael@0: * @return Iterator that returns Header objects in the sequence they are
michael@0: * sent over a connection.
michael@0: */
michael@0: HeaderIterator headerIterator();
michael@0:
michael@0: /**
michael@0: * Returns an iterator of the headers with a given name.
michael@0: *
michael@0: * @param name the name of the headers over which to iterate, or
michael@0: * null
for all headers
michael@0: *
michael@0: * @return Iterator that returns Header objects with the argument name
michael@0: * in the sequence they are sent over a connection.
michael@0: */
michael@0: HeaderIterator headerIterator(String name);
michael@0:
michael@0: /**
michael@0: * Returns the parameters effective for this message as set by
michael@0: * {@link #setParams(HttpParams)}.
michael@0: */
michael@0: HttpParams getParams();
michael@0:
michael@0: /**
michael@0: * Provides parameters to be used for the processing of this message.
michael@0: * @param params the parameters
michael@0: */
michael@0: void setParams(HttpParams params);
michael@0:
michael@0: }