org.apache.hc.core5.http.message

## Class BufferedHeader

- java.lang.Object
- - org.apache.hc.core5.http.message.BufferedHeader

- All Implemented Interfaces:
    Serializable, FormattedHeader, Header, NameValuePair

      public class BufferedHeader
      extends Object
      implements FormattedHeader, Serializable

  This class represents a raw HTTP header whose content is parsed 'on demand' only when the header value needs to be consumed.
  Since:
    4.0
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BufferedHeader(CharArrayBuffer buffer)` Creates a new header from a buffer.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static BufferedHeader` | `create(CharArrayBuffer buffer)`
    `CharArrayBuffer` | `getBuffer()` Obtains the buffer with the formatted header.
    `String` | `getName()` Gets the name of this pair.
    `String` | `getValue()` Gets the value of this pair.
    `int` | `getValuePos()` Obtains the start of the header value in the `buffer`.
    `boolean` | `isSensitive()` Returns `true` if the header should be considered sensitive.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### BufferedHeader

          public BufferedHeader(CharArrayBuffer buffer)
                         throws ParseException

      Creates a new header from a buffer. The name of the header will be parsed immediately, the value only if it is accessed.
      Parameters:
        `buffer` - the buffer containing the header to represent
      Throws:
        `ParseException` - in case of a parse error

  - ### Method Detail

    - #### create

          public static BufferedHeader create(CharArrayBuffer buffer)

      Since:
        5.0

    - #### getName

          public String getName()

      Description copied from interface: `NameValuePair`
      Gets the name of this pair.
      Specified by:
        `getName` in interface `NameValuePair`
      Returns:
        the name of this pair, never `null`.

    - #### getValue

          public String getValue()

      Description copied from interface: `NameValuePair`
      Gets the value of this pair.
      Specified by:
        `getValue` in interface `NameValuePair`
      Returns:
        the value of this pair, may be `null`.

    - #### isSensitive

          public boolean isSensitive()

      Description copied from interface: `Header`
      Returns `true` if the header should be considered sensitive.

      Some encoding schemes such as HPACK impose restrictions on encoded representation of sensitive headers.

      Specified by:
        `isSensitive` in interface `Header`
      Returns:
        `true` if the header should be considered sensitive.

    - #### getValuePos

          public int getValuePos()

      Description copied from interface: `FormattedHeader`
      Obtains the start of the header value in the `buffer`. By accessing the value in the buffer, creation of a temporary string can be avoided.
      Specified by:
        `getValuePos` in interface `FormattedHeader`
      Returns:
        index of the first character of the header value in the buffer returned by `getBuffer`.

    - #### getBuffer

          public CharArrayBuffer getBuffer()

      Description copied from interface: `FormattedHeader`
      Obtains the buffer with the formatted header. The returned buffer MUST NOT be modified.
      Specified by:
        `getBuffer` in interface `FormattedHeader`
      Returns:
        the formatted header, in a buffer that must not be modified

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

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