Request

final class Request[+F[_]] extends Message[F] with Product with Serializable

Representation of an incoming HTTP message

A Request encapsulates the entirety of the incoming HTTP request including the status line, headers, and a possible request body.

Value parameters:
attributes

Immutable Map used for carrying additional information in a type safe fashion

entity

Entity defining the body of the request

headers

collection of Headers

httpVersion

the HTTP version

method

Method.GET, Method.POST, etc.

uri

representation of the request URI

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

Type members

Types

type SelfF[F0[_]] = Request[F0]

Value members

Concrete methods

Add a Cookie header for the provided org.http4s.headers.Cookie

Add a Cookie header for the provided org.http4s.headers.Cookie

Source:
Message.scala
def addCookie(name: String, content: String): Request[F]

Add a Cookie header with the provided values

Add a Cookie header with the provided values

Source:
Message.scala
def asCurl(redactHeadersWhen: CIString => Boolean): String

cURL representation of the request.

cURL representation of the request.

Supported cURL-Parameters are: --request, --url, --header. Note that asCurl will not print the request body.

Source:
Message.scala
def canEqual(that: Any): Boolean

Parses all available org.http4s.headers.Cookie headers into a list of RequestCookie objects. This implementation is compatible with cookie headers formatted per HTTP/1 and HTTP/2, or even both at the same time.

Parses all available org.http4s.headers.Cookie headers into a list of RequestCookie objects. This implementation is compatible with cookie headers formatted per HTTP/1 and HTTP/2, or even both at the same time.

Source:
Message.scala
def decode[F2[x], A](f: A => F2[Response[F2]])(implicit F: Monad[F2], decoder: EntityDecoder[F2, A]): F2[Response[F2]]

Helper method for decoding Requests

Helper method for decoding Requests

Attempt to decode the Request and, if successful, execute the continuation to get a Response. If decoding fails, an UnprocessableEntity Response is generated.

Source:
Message.scala
def decodeStrict[F2[x], A](f: A => F2[Response[F2]])(implicit F: Monad[F2], decoder: EntityDecoder[F2, A]): F2[Response[F2]]

Helper method for decoding Requests

Helper method for decoding Requests

Attempt to decode the Request and, if successful, execute the continuation to get a Response. If decoding fails, an UnprocessableEntity Response is generated. If the decoder does not support the MediaType of the Request, a UnsupportedMediaType Response is generated instead.

Source:
Message.scala
def decodeWith[F2[x], A](decoder: EntityDecoder[F2, A], strict: Boolean)(f: A => F2[Response[F2]])(implicit F: Monad[F2]): F2[Response[F2]]

Returns the the X-Forwarded-For value if present, else the remote address.

Returns the the X-Forwarded-For value if present, else the remote address.

Source:
Message.scala

Checks whether the Entity of the Message is pure in the sense of indicating that the entity body can be re-run without side effects.

Checks whether the Entity of the Message is pure in the sense of indicating that the entity body can be re-run without side effects.

Returns:

the Boolean value: 'true' if entity is empty or already loaded into memory; 'false' if entity is streamed.

Source:
Message.scala
override def hashCode(): Int
Definition Classes
Any
Source:
Message.scala

A request is idempotent if its method is idempotent or it contains an Idempotency-Key header.

A request is idempotent if its method is idempotent or it contains an Idempotency-Key header.

Source:
Message.scala

Whether the Request was received over a secure medium

Whether the Request was received over a secure medium

Source:
Message.scala

Representation of the query string as a map

Representation of the query string as a map

In case a parameter is available in query string but no value is there the list will be empty. If the value is empty the the list contains an empty string.

=====Examples=====

Query StringMap
?param=vMap("param" -> List("v"))
?param=Map("param" -> List(""))
?paramMap("param" -> List())
?=valueMap("" -> List("value"))
?p1=v1&p1=v2&p2=v3&p2=v4Map("p1" -> List("v1","v2"), "p2" -> List("v3","v4"))

The query string is lazily parsed. If an error occurs during parsing an empty Map is returned.

Source:
Message.scala

View of the head elements of the URI parameters in query string.

View of the head elements of the URI parameters in query string.

In case a parameter has no value the map returns an empty string.

See also:

multiParams

Source:
Message.scala
def productElement(n: Int): Any
def remoteHost[F1[x]](implicit F: Monad[F1], dns: Dns[F1]): F1[Option[Hostname]]

A projection of this request without the body.

A projection of this request without the body.

Source:
Message.scala
override def toString: String
Definition Classes
Any
Source:
Message.scala
def withMethod(method: Method): Request[F]
def withUri(uri: Uri): Request[F]

Deprecated methods

@deprecated(message = "Use {withPathInfo(Uri.Path)} instead", since = "0.22.0-M1")
Deprecated
[Since version 0.22.0-M1] Use {withPathInfo(Uri.Path)} instead
Source:
Message.scala

Inherited methods

def addHeader[H : ([H] =>> Header[H, Recurring])](h: H): Request[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/*)))

////*/

Inherited from:
Message
Source:
Message.scala
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
override def covary[F2[x]]: Request[F2]

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

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

Definition Classes
Inherited from:
Message
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

Inherited from:
Message
Source:
Message.scala
Inherited from:
Message
Source:
Message.scala
def mapK[F2[x], G[_]](f: FunctionK[F2, G]): Request[G]
Inherited from:
Message
Source:
Message.scala
Inherited from:
Product
Inherited from:
Product
Inherited from:
Product
def putHeaders(headers: ToRaw*): Request[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/*)))

////

Inherited from:
Message
Source:
Message.scala
def removeHeader[A](implicit h: Header[A, _]): Request[F]
Inherited from:
Message
Source:
Message.scala
def removeHeader(key: CIString): Request[F]
Inherited from:
Message
Source:
Message.scala
def toStrict[F1[x]](maxBytes: Option[Long])(implicit F: Concurrent[F1]): F1[Request[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.

Inherited from:
Message
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.

Inherited from:
Message
Source:
Message.scala
Inherited from:
Message
Source:
Message.scala
def withAttribute[A](key: Key[A], value: A): Request[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

Inherited from:
Message
Source:
Message.scala
def withAttributes(attributes: Vault): Request[F]
Inherited from:
Message
Source:
Message.scala
def withBodyStream[F1[x]](body: EntityBody[F1]): Request[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.

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

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.

Inherited from:
Message
Source:
Message.scala
def withEntity[F1[x]](entity: Entity[F1]): Request[F1]
Inherited from:
Message
Source:
Message.scala
def withEntity[F1[x], T](b: T)(implicit w: EntityEncoder[F1, T]): Request[F1]

Replace the body of this message with a new body

Replace the body of this message with a new body

Type parameters:
T

type of the Body

Value parameters:
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

Inherited from:
Message
Source:
Message.scala
def withHeaders(headers: ToRaw*): Request[F]
Inherited from:
Message
Source:
Message.scala
def withHeaders(headers: Headers): Request[F]
Inherited from:
Message
Source:
Message.scala
def withHttpVersion(httpVersion: HttpVersion): Request[F]
Inherited from:
Message
Source:
Message.scala
def withTrailerHeaders[F1[x]](trailerHeaders: F1[Headers]): Request[F1]
Inherited from:
Message
Source:
Message.scala
def withoutAttribute(key: Key[_]): Request[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

Inherited from:
Message
Source:
Message.scala
Inherited from:
Message
Source:
Message.scala