org.apache.hc.core5.http

## Interface MessageHeaders

- All Known Subinterfaces:
    ClassicHttpRequest, ClassicHttpResponse, HttpMessage, HttpRequest, HttpResponse
  All Known Implementing Classes:
    AbstractMessageWrapper, BasicClassicHttpRequest, BasicClassicHttpResponse, BasicHttpRequest, BasicHttpResponse, HeaderGroup, HttpRequestWrapper, HttpResponseWrapper

      public interface MessageHeaders

  Messages head consisting of multiple message headers.
  Since:
    5.0

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `containsHeader(String name)` Checks if a certain header is present in this message.
    `int` | `countHeaders(String name)` Checks if a certain header is present in this message and how many times.
    `Header` | `getFirstHeader(String name)` Returns the first header with a specified name of this message.
    `Header` | `getHeader(String name)` Gets single first header with the given name.
    `Header[]` | `getHeaders()` Returns all the headers of this message.
    `Header[]` | `getHeaders(String name)` Returns all the headers with a specified name of this message.
    `Header` | `getLastHeader(String name)` Returns the last header with a specified name of this message.
    `Iterator<Header>` | `headerIterator()` Returns an iterator of all the headers.
    `Iterator<Header>` | `headerIterator(String name)` Returns an iterator of the headers with a given name.

- - ### Method Detail

    - #### containsHeader

          boolean containsHeader(String name)

      Checks if a certain header is present in this message. Header values are ignored.
      Parameters:
        `name` - the header name to check for.
      Returns:
        true if at least one header with this name is present.

    - #### countHeaders

          int countHeaders(String name)

      Checks if a certain header is present in this message and how many times.
      Parameters:
        `name` - the header name to check for.
      Returns:
        number of occurrences of the header in the message.

    - #### getFirstHeader

          Header getFirstHeader(String name)

      Returns the first header with a specified name of this message. Header values are ignored. If there is more than one matching header in the message the first element of `getHeaders(String)` is returned. If there is no matching header in the message `null` is returned.
      Parameters:
        `name` - the name of the header to return.
      Returns:
        the first header whose name property equals `name` or `null` if no such header could be found.

    - #### getHeader

          Header getHeader(String name)
                           throws ProtocolException

      Gets single first header with the given name.

      Header name comparison is case insensitive.

      Parameters:
        `name` - the name of the header to get
      Returns:
        the first header or `null`
      Throws:
        `ProtocolException` - in case multiple headers with the given name are found.

    - #### getHeaders

          Header[] getHeaders()

      Returns all the headers of this message. Headers are ordered in the sequence they will be sent over a connection.
      Returns:
        all the headers of this message

    - #### getHeaders

          Header[] getHeaders(String name)

      Returns all the headers with a specified name of this message. Header values are ignored. Headers are ordered in the sequence they will be sent over a connection.
      Parameters:
        `name` - the name of the headers to return.
      Returns:
        the headers whose name property equals `name`.

    - #### getLastHeader

          Header getLastHeader(String name)

      Returns the last header with a specified name of this message. Header values are ignored. If there is more than one matching header in the message the last element of `getHeaders(String)` is returned. If there is no matching header in the message `null` is returned.
      Parameters:
        `name` - the name of the header to return.
      Returns:
        the last header whose name property equals `name`. or `null` if no such header could be found.

    - #### headerIterator

          Iterator<Header> headerIterator()

      Returns an iterator of all the headers.
      Returns:
        Iterator that returns Header objects in the sequence they are sent over a connection.

    - #### headerIterator

          Iterator<Header> headerIterator(String name)

      Returns an iterator of the headers with a given name.
      Parameters:
        `name` - the name of the headers over which to iterate, or `null` for all headers
      Returns:
        Iterator that returns Header objects with the argument name in the sequence they are sent over a connection.

Copyright © 2005–2022 The Apache Software Foundation. All rights reserved.