sealed trait Message[F[_]] extends Media[F]
Represents a HTTP Message. The interesting subclasses are Request and Response.
- Self Type
- Message[F]
- Source
- Message.scala
- Alphabetic
- By Inheritance
- Message
- Media
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
Abstract Value Members
- abstract def attributes: Vault
- abstract def body: EntityBody[F]
- abstract def headers: Headers
- abstract def httpVersion: HttpVersion
Concrete Value Members
-
def
addHeader[H](h: H)(implicit arg0: Header[H, Recurring]): Self
Add a header to these headers.
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 cats.effect.IO >>> import org.http4s.headers.Accept >>> val req = Request[IO]().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/*)))
*/*/*/*/*/
-
final
def
as[A](implicit F: MonadThrow[F], decoder: EntityDecoder[F, A]): F[A]
Decode the Media to the specified type
- A
type of the result
- decoder
EntityDecoder used to decode the Media
- returns
the effect which will generate the A
- Definition Classes
- Media
-
final
def
attemptAs[T](implicit decoder: EntityDecoder[F, T]): DecodeResult[F, T]
Decode the Media to the specified type
Decode the Media to the specified type
- T
type of the result
- decoder
EntityDecoder used to decode the Media
- returns
the effect which will generate the
DecodeResult[T]
- Definition Classes
- Media
-
final
def
bodyText(implicit RT: RaiseThrowable[F], defaultCharset: Charset = DefaultCharset): Stream[F, String]
- Definition Classes
- Media
-
final
def
charset: Option[Charset]
- Definition Classes
- Media
-
final
def
contentLength: Option[Long]
- Definition Classes
- Media
-
final
def
contentType: Option[Content-Type]
- Definition Classes
- Media
-
def
covary[F2[x] >: F[x]]: SelfF[F2]
Lifts this Message's body to the specified effect type.
-
def
filterHeaders(f: (Raw) ⇒ Boolean): Self
Keep headers that satisfy the predicate
Keep headers that satisfy the predicate
- f
predicate
- returns
a new message object which has only headers that satisfy the predicate
- def isChunked: Boolean
-
def
putHeaders(headers: ToRaw*): Self
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 cats.effect.IO >>> import org.http4s.headers.Accept >>> val req = Request[IO]().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/*)))
*/*/*/*/
- def removeHeader[A](implicit h: Header[A, _]): Self
- def removeHeader(key: CIString): Self
-
def
trailerHeaders(implicit F: Applicative[F]): F[Headers]
The trailer headers, as specified in Section 3.6.1 of RFC 2616.
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.
- def transformHeaders(f: (Headers) ⇒ Headers): Self
-
def
withAttribute[A](key: Key[A], value: A): Self
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.
- A
type of the value to store
- key
io.chrisdavenport.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
- def withAttributes(attributes: Vault): Self
-
def
withBodyStream(body: EntityBody[F]): Self
Sets the entity body without affecting headers such as
Transfer-Encoding
orContent-Length
.Sets the entity body without affecting headers such as
Transfer-Encoding
orContent-Length
. Most use cases are better served by withEntity, which uses an EntityEncoder to maintain the headers. - def withContentType(contentType: Content-Type): Self
- def withContentTypeOption(contentTypeO: Option[Content-Type]): Self
-
def
withEmptyBody: Self
Set an empty entity body on this message, and remove all payload headers that make no sense with an empty body.
-
def
withEntity[T](b: T)(implicit w: EntityEncoder[F, T]): Self
Replace the body of this message with a new body
Replace the body of this message with a new body
- T
type of the Body
- b
body to attach to this method
- w
EntityEncoder with which to convert the body to an EntityBody
- returns
a new message with the new body
- def withHeaders(headers: ToRaw*): Self
- def withHeaders(headers: Headers): Self
- def withHttpVersion(httpVersion: HttpVersion): Self
- def withTrailerHeaders(trailerHeaders: F[Headers]): Self
-
def
withoutAttribute(key: Key[_]): Self
Returns a new message object without the specified key in the #attributes.
Returns a new message object without the specified key in the #attributes.
- key
io.chrisdavenport.vault.Key to remove
- returns
a new message object without the key
- def withoutContentType: Self
- def withoutTrailerHeaders: Self
Deprecated Value Members
-
def
withBody[T](b: T)(implicit F: Applicative[F], w: EntityEncoder[F, T]): F[Self]
- Annotations
- @deprecated
- Deprecated
(Since version 0.19) Use withEntity
-
def
withType(t: MediaType)(implicit F: Functor[F]): Self
- Annotations
- @deprecated
- Deprecated
(Since version 0.20.0-M2) Use withContentType(
Content-Type
(t)) instead