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

Value members

Concrete methods

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[ev.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.

Value parameters

key

name of the headers to find.

Attributes

Returns

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

Source
Headers.scala

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

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.

Value parameters

end

the ending string

redactWhen

the function for filtering out header values of sensitive headers

separator

the separator string

start

the starting string

Attributes

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

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.

Value parameters

redactWhen

the function for filtering out header values of sensitive headers

separator

the separator string

Attributes

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.

Value parameters

in

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

Attributes

Returns

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

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
def transform(f: (List[Raw]) => List[Raw]): Headers

Attributes

Source
Headers.scala

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)

Attributes

Source
Headers.scala

Concrete fields

val headers: List[Raw]

Attributes

Source
Headers.scala