Headers

org.http4s.Headers
See theHeaders companion object
final class Headers(val headers: List[Raw]) extends AnyVal

A collection of HTTP Headers

Attributes

Companion:
object
Source:
Headers.scala
Graph
Supertypes
class AnyVal
trait Matchable
class Any

Members list

Concise view

Value members

Concrete methods

def ++(those: Headers): Headers

Attributes

Source:
Headers.scala
def add[H : ([H] =>> Header[H, Recurring])](h: H): Headers

Attributes

Source:
Headers.scala
def contains[A](implicit ev: Header[A, _]): Boolean

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

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

Attributes

Source:
Headers.scala
def foreach(f: Raw => Unit): Unit

Attributes

Source:
Headers.scala
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.

Attributes

Returns:

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

Source:
Headers.scala

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

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

Attributes

key

name of the headers to find.

Returns:

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

Source:
Headers.scala
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.

Attributes

Returns:

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

Source:
Headers.scala
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.

Attributes

end

the ending string

redactWhen

the function for filtering out header values of sensitive headers

separator

the separator string

start

the starting string

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.

Source:
Headers.scala
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.

Attributes

redactWhen

the function for filtering out header values of sensitive headers

separator

the separator string

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.

Source:
Headers.scala
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.

Attributes

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

Source:
Headers.scala

Attributes

Source:
Headers.scala

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

Attributes

Source:
Headers.scala
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns:

a string representation of the object.

Definition Classes
Any
Source:
Headers.scala

Attributes

Source:
Headers.scala

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.

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)

Attributes

Source:
Headers.scala

Concrete fields

Attributes

Source:
Headers.scala