org.apache.hc.core5.http

## Interface HttpMessage

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

      public interface HttpMessage
      extends MessageHeaders

  HTTP messages consist of requests from client to server and responses from server to client.
  Since:
    4.0

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addHeader(Header header)` Adds a header to this message.
    `void` | `addHeader(String name, Object value)` Adds a header to this message.
    `ProtocolVersion` | `getVersion()` Returns protocol version or `null` when not available.
    `boolean` | `removeHeader(Header header)` Removes a header from this message.
    `boolean` | `removeHeaders(String name)` Removes all headers with a certain name from this message.
    `void` | `setHeader(Header header)` Overwrites the first header with the same name.
    `void` | `setHeader(String name, Object value)` Overwrites the first header with the same name.
    `void` | `setHeaders(Header... headers)` Overwrites all the headers in the message.
    `void` | `setVersion(ProtocolVersion version)` Sets protocol version.

    - ### Methods inherited from interface org.apache.hc.core5.http.MessageHeaders

      `containsHeader, countHeaders, getFirstHeader, getHeader, getHeaders, getHeaders, getLastHeader, headerIterator, headerIterator`

- - ### Method Detail

    - #### setVersion

          void setVersion(ProtocolVersion version)

      Sets protocol version.

      For incoming messages it represents protocol version this message was transmitted with. For outgoing messages it represents a hint what protocol version should be used to transmit the message.

      Since:
        5.0

    - #### getVersion

          ProtocolVersion getVersion()

      Returns protocol version or `null` when not available.

      For incoming messages it represents protocol version this message was transmitted with. For outgoing messages it represents a hint what protocol version should be used to transmit the message.

      Since:
        5.0

    - #### addHeader

          void addHeader(Header header)

      Adds a header to this message. The header will be appended to the end of the list.
      Parameters:
        `header` - the header to append.

    - #### addHeader

          void addHeader(String name,
                       Object value)

      Adds a header to this message. The header will be appended to the end of the list.
      Parameters:
        `name` - the name of the header.
        `value` - the value of the header, taken as the value's `Object.toString()`.

    - #### setHeader

          void setHeader(Header header)

      Overwrites the first header with the same name. The new header will be appended to the end of the list, if no header with the given name can be found.
      Parameters:
        `header` - the header to set.

    - #### setHeader

          void setHeader(String name,
                       Object value)

      Overwrites the first header with the same name. The new header will be appended to the end of the list, if no header with the given name can be found.
      Parameters:
        `name` - the name of the header.
        `value` - the value of the header, taken as the value's `Object.toString()`.

    - #### setHeaders

          void setHeaders(Header... headers)

      Overwrites all the headers in the message.
      Parameters:
        `headers` - the array of headers to set.

    - #### removeHeader

          boolean removeHeader(Header header)

      Removes a header from this message.
      Parameters:
        `header` - the header to remove.
      Returns:
        `true` if a header was removed as a result of this call.

    - #### removeHeaders

          boolean removeHeaders(String name)

      Removes all headers with a certain name from this message.
      Parameters:
        `name` - The name of the headers to remove.
      Returns:
        `true` if any header was removed as a result of this call.

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