Packages

final class Headers extends AnyVal

A collection of HTTP Headers

Source
Headers.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Headers
  2. AnyVal
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new Headers(headers: List[Raw])

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    Any
  2. final def ##: Int
    Definition Classes
    Any
  3. def ++(those: Headers): Headers
  4. final def ==(arg0: Any): Boolean
    Definition Classes
    Any
  5. def add[H](h: H)(implicit arg0: Header[H, Recurring]): Headers
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def contains[A](implicit ev: Header[A, _]): Boolean

    Returns true if there is at least one header by the specified name.

  8. def foreach(f: (Raw) => Unit): Unit
  9. def get(key: CIString): Option[NonEmptyList[Raw]]

    Attempt to get headers by key from this collection of headers.

    Attempt to get headers by key from this collection of headers.

    key

    name of the headers to find.

    returns

    a scala.Option possibly containing the resulting collection cats.data.NonEmptyList of org.http4s.Header.Raw.

  10. def get[A](implicit ev: Select[A]): Option[F[A]]

    Attempt to get a (potentially repeating) header from this collection of headers.

    Attempt to get a (potentially repeating) header from this collection of headers.

    returns

    a scala.Option possibly containing the resulting (potentially repeating) header.

  11. def getClass(): Class[_ <: AnyVal]
    Definition Classes
    AnyVal → Any
  12. def getWithWarnings[A](implicit ev: Select[A]): Option[Ior[NonEmptyList[ParseFailure], F[A]]]

    Attempt to get a (potentially repeating) header and/or any parse errors from this collection of headers.

    Attempt to get a (potentially repeating) header and/or any parse errors from this collection of headers.

    returns

    a scala.Option possibly containing the resulting (potentially repeating) header and/or any parse errors.

  13. val headers: List[Raw]
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. def mkString(separator: String, redactWhen: (CIString) => Boolean): String

    Creates a string representation for a list of headers and redacts sensitive headers' values.

    Creates a string representation for a list of headers and redacts sensitive headers' values.

    separator

    the separator string

    redactWhen

    the function for filtering out header values of sensitive headers

    returns

    a string representation of the list of headers. The resulting string is constructed from the string representations of all headers separated by the string separator. Sensitive headers' values are redacted with the redactWhen function.

  16. def mkString(start: String, separator: String, end: String, redactWhen: (CIString) => Boolean): String

    Creates a string representation for a list of headers and redacts sensitive headers' values.

    Creates a string representation for a list of headers and redacts sensitive headers' values.

    start

    the starting string

    separator

    the separator string

    end

    the ending string

    redactWhen

    the function for filtering out header values of sensitive headers

    returns

    a string representation of the list of headers. The resulting string begins with the string start and ends with the string end. Inside, the string representations of all headers are separated by the string separator. Sensitive headers' values are redacted with the redactWhen function.

  17. def put(in: ToRaw*): Headers

    Make a new collection adding the specified headers, replacing existing Single headers.

    Make a new collection adding the specified headers, replacing existing Single headers.

    in

    multiple heteregenous headers Header to append to the new collection, see Header.ToRaw

    returns

    a new Headers containing the sum of the initial and input headers

  18. def redactSensitive(redactWhen: (CIString) => Boolean = Headers.SensitiveHeaders.contains): Headers
  19. def removePayloadHeaders: Headers

    Removes the Content-Length, Content-Range, Trailer, and Transfer-Encoding headers.

    Removes the Content-Length, Content-Range, Trailer, and Transfer-Encoding headers.

    https://datatracker.ietf.org/doc/html/rfc7231#section-3.3

  20. def toString(): String
    Definition Classes
    Headers → Any
  21. def transform(f: (List[Raw]) => List[Raw]): Headers
  22. def withContentLength(contentLength: Content-Length): Headers

    Puts a Content-Length header, replacing any existing.

    Puts a Content-Length header, replacing any existing. Removes any existing chunked value from the Transfer-Encoding header. It is critical that the supplied content length accurately describe the length of the body stream.

    scala> import org.http4s.headers._
    scala> val chunked = Headers(
         |   `Transfer-Encoding`(TransferCoding.chunked),
         |   `Content-Type`(MediaType.text.plain))
    scala> chunked.withContentLength(`Content-Length`.unsafeFromLong(1024))
    res0: Headers = Headers(Content-Length: 1024, Content-Type: text/plain)
    
    scala> val chunkedGzipped = Headers(
         |   `Transfer-Encoding`(TransferCoding.chunked, TransferCoding.gzip),
         |   `Content-Type`(MediaType.text.plain))
    scala> chunkedGzipped.withContentLength(`Content-Length`.unsafeFromLong(1024))
    res1: Headers = Headers(Content-Length: 1024, Transfer-Encoding: gzip, Content-Type: text/plain)
    
    scala> val const = Headers(
         |   `Content-Length`(2048),
         |   `Content-Type`(MediaType.text.plain))
    scala> const.withContentLength(`Content-Length`.unsafeFromLong(1024))
    res1: Headers = Headers(Content-Length: 1024, Content-Type: text/plain)

Inherited from AnyVal

Inherited from Any

Ungrouped