Message

sealed trait Message[+F[_]] extends Media[F]

Represents a HTTP Message. The interesting subclasses are Request and Response.

Companion:
object
Source:
Message.scala
trait Media[F]
class Object
trait Matchable
class Any
class Request[F]
class Response[F]

Type members

Types

type SelfF[+F2[_]] <: Message[F2] { type SelfF = [F3[_]] =>> SelfF[F3]; }

Value members

Abstract methods

Concrete methods

def addHeader[H : ([H] =>> Header[H, Recurring])](h: H): SelfF[F]

Add a header to these headers. The header should be a type with a recurring Header instance to ensure that the new value can be appended to any existing values.

Add a header to these headers. The header should be a type with a recurring Header instance to ensure that the new value can be appended to any existing values.

>>> import org.http4s.headers.Accept

>>> val req = Request().addHeader(Accept(MediaRange.`application/*`))
>>> req.headers.get[Accept]
Some(Accept(NonEmptyList(application/*)))

>>> val req2 = req.addHeader(Accept(MediaRange.`text/*`))
>>> req2.headers.get[Accept]
Some(Accept(NonEmptyList(application/*, text/*)))

////*/

Source:
Message.scala
override def covary[F2[x]]: SelfF[F2]

Lifts this Message's body to the specified effect type.

Lifts this Message's body to the specified effect type.

Definition Classes
Source:
Message.scala

Keep headers that satisfy the predicate

Keep headers that satisfy the predicate

Value parameters:
f

predicate

Returns:

a new message object which has only headers that satisfy the predicate

Source:
Message.scala
def mapK[F2[x], G[_]](f: FunctionK[F2, G]): SelfF[G]
def putHeaders(headers: ToRaw*): SelfF[F]

Add the provided headers to the existing headers, replacing those of the same header name

Add the provided headers to the existing headers, replacing those of the same header name

>>> import org.http4s.headers.Accept

>>> val req = Request().putHeaders(Accept(MediaRange.`application/*`))
>>> req.headers.get[Accept]
Some(Accept(NonEmptyList(application/*)))

>>> val req2 = req.putHeaders(Accept(MediaRange.`text/*`))
>>> req2.headers.get[Accept]
Some(Accept(NonEmptyList(text/*)))

////

Source:
Message.scala
def removeHeader[A](implicit h: Header[A, _]): SelfF[F]
def toStrict[F1[x]](maxBytes: Option[Long])(implicit F: Concurrent[F1]): F1[SelfF[Pure]]

Compiles the body stream to a single chunk and sets it as the body. Replaces any Transfer-Encoding: chunked with a Content-Length header. It is the caller's responsibility to assure there is enough memory to materialize the entity body and control the time limits of that materialization.

Compiles the body stream to a single chunk and sets it as the body. Replaces any Transfer-Encoding: chunked with a Content-Length header. It is the caller's responsibility to assure there is enough memory to materialize the entity body and control the time limits of that materialization.

Value parameters:
maxBytes

maximum length of the entity stream. If the stream exceeds the limit then processing fails with the Message.EntityStreamException. Pass the scala.None if you don't want to limit the entity body.

Source:
Message.scala
def trailerHeaders[F1[x]](implicit F: Applicative[F1]): F1[Headers]

The trailer headers, as specified in Section 3.6.1 of RFC 2616. The resulting F might not complete until the entire body has been consumed.

The trailer headers, as specified in Section 3.6.1 of RFC 2616. The resulting F might not complete until the entire body has been consumed.

Source:
Message.scala
def withAttribute[A](key: Key[A], value: A): SelfF[F]

Generates a new message object with the specified key/value pair appended to the attributes.

Generates a new message object with the specified key/value pair appended to the attributes.

Type parameters:
A

type of the value to store

Value parameters:
key

org.typelevel.vault.Key with which to associate the value

value

value associated with the key

Returns:

a new message object with the key/value pair appended

Source:
Message.scala
def withAttributes(attributes: Vault): SelfF[F]
def withBodyStream[F1[x]](body: EntityBody[F1]): SelfF[F1]

Sets the entity body without affecting headers such as Transfer-Encoding or Content-Length. Most use cases are better served by [[withEntity[F1[x]](entity*]], which uses an EntityEncoder to maintain the headers.

Sets the entity body without affecting headers such as Transfer-Encoding or Content-Length. Most use cases are better served by [[withEntity[F1[x]](entity*]], which uses an EntityEncoder to maintain the headers.

WARNING: this method does not modify the headers of the message, and as a consequence headers may be incoherent with the body.

Source:
Message.scala
def withContentType(contentType: Content-Type): SelfF[F]

Set an Entity.Empty entity on this message, and remove all payload headers that make no sense with an empty body.

Set an Entity.Empty entity on this message, and remove all payload headers that make no sense with an empty body.

Source:
Message.scala
def withEntity[F1[x]](entity: Entity[F1]): SelfF[F1]
def withHeaders(headers: Headers): SelfF[F]
def withHeaders(headers: ToRaw*): SelfF[F]
def withHttpVersion(httpVersion: HttpVersion): SelfF[F]
def withTrailerHeaders[F1[x]](trailerHeaders: F1[Headers]): SelfF[F1]
def withoutAttribute(key: Key[_]): SelfF[F]

Returns a new message object without the specified key in the attributes.

Returns a new message object without the specified key in the attributes.

Value parameters:
key

org.typelevel.vault.Key to remove

Returns:

a new message object without the key

Source:
Message.scala

Inherited methods

final def body: EntityBody[F]
Inherited from:
Media
Source:
Media.scala
final def bodyText[F2[x]](implicit RT: RaiseThrowable[F2], defaultCharset: Charset): Stream[F2, String]
Inherited from:
Media
Source:
Media.scala
final def charset: Option[Charset]
Inherited from:
Media
Source:
Media.scala
Inherited from:
Media
Source:
Media.scala
Inherited from:
Media
Source:
Media.scala
def entity: Entity[F]
Inherited from:
Media
Source:
Media.scala
Inherited from:
Media
Source:
Media.scala