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.
- Source
- Message.scala
- Alphabetic
- By Inheritance
- Request
- Serializable
- Serializable
- Product
- Equals
- Message
- Media
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
addCookie(name: String, content: String): Request[F]
Add a Cookie header with the provided values
-
def
addCookie(cookie: RequestCookie): Request[F]
Add a Cookie header for the provided org.http4s.headers.Cookie
-
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/*)))
*/*/*/*/*/
- Definition Classes
- Message
-
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
-
def
asCurl(redactHeadersWhen: (CIString) ⇒ Boolean = Headers.SensitiveHeaders.contains): String
cURL representation of the request.
cURL representation of the request.
Supported cURL-Parameters are: -X, -H
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
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
- val attributes: Vault
- def authType: Option[AuthScheme]
- val body: EntityBody[F]
-
final
def
bodyText(implicit RT: RaiseThrowable[F], defaultCharset: Charset = DefaultCharset): Stream[F, String]
- Definition Classes
- Media
-
def
canEqual(that: Any): Boolean
- Definition Classes
- Request → Equals
- def change(httpVersion: HttpVersion, body: EntityBody[F], headers: Headers, attributes: Vault): Request[F]
-
final
def
charset: Option[Charset]
- Definition Classes
- Media
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
contentLength: Option[Long]
- Definition Classes
- Media
-
final
def
contentType: Option[Content-Type]
- Definition Classes
- Media
-
def
cookies: List[RequestCookie]
Parses all available org.http4s.headers.Cookie headers into a list of RequestCookie objects.
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.
-
def
covary[F2[x] >: F[x]]: SelfF[F2]
Lifts this Message's body to the specified effect type.
-
def
decode[A](f: (A) ⇒ F[Response[F]])(implicit F: Monad[F], decoder: EntityDecoder[F, A]): F[Response[F]]
Helper method for decoding Requests
-
def
decodeStrict[A](f: (A) ⇒ F[Response[F]])(implicit F: Monad[F], decoder: EntityDecoder[F, A]): F[Response[F]]
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, aUnsupportedMediaType
Response is generated instead. - def decodeWith[A](decoder: EntityDecoder[F, A], strict: Boolean)(f: (A) ⇒ F[Response[F]])(implicit F: Monad[F]): F[Response[F]]
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
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
- Definition Classes
- Message
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
from: Option[IpAddress]
Returns the the X-Forwarded-For value if present, else the remote address.
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- Request → AnyRef → Any
- val headers: Headers
- val httpVersion: HttpVersion
-
def
isChunked: Boolean
- Definition Classes
- Message
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isSecure: Option[Boolean]
Whether the Request was received over a secure medium
- def mapK[G[_]](f: ~>[F, G]): Request[G]
- val method: Method
-
def
multiParams: Map[String, Seq[String]]
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 sequence will be empty. If the value is empty the the sequence contains an empty string.
Examples
Query String Map ?param=v
Map("param" -> Seq("v"))
?param=
Map("param" -> Seq(""))
?param
Map("param" -> Seq())
?=value
Map("" -> Seq("value"))
?p1=v1&p1=v2&p2=v3&p2=v3
Map("p1" -> Seq("v1","v2"), "p2" -> Seq("v3","v4"))
The query string is lazily parsed. If an error occurs during parsing an empty
Map
is returned. -
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
params: Map[String, String]
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
- lazy val pathInfo: Path
- def pathTranslated: Option[File]
-
def
productArity: Int
- Definition Classes
- Request → Product
-
def
productElement(n: Int): Any
- Definition Classes
- Request → Product
-
def
productIterator: Iterator[Any]
- Definition Classes
- Product
-
def
productPrefix: String
- Definition Classes
- Product
-
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/*)))
*/*/*/*/
- Definition Classes
- Message
- def queryString: String
- def remote: Option[SocketAddress[IpAddress]]
- def remoteAddr: Option[IpAddress]
- def remoteHost(implicit F: Sync[F]): F[Option[Hostname]]
- def remotePort: Option[Port]
- def remoteUser: Option[String]
-
def
removeHeader[A](implicit h: Header[A, _]): Self
- Definition Classes
- Message
-
def
removeHeader(key: CIString): Self
- Definition Classes
- Message
-
def
requestPrelude: RequestPrelude
A projection of this request without the body.
- lazy val scriptName: Path
- def server: Option[SocketAddress[IpAddress]]
- def serverAddr: Option[IpAddress]
- def serverPort: Option[Port]
- def serverSoftware: ServerSoftware
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- Request → AnyRef → Any
-
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.
- Definition Classes
- Message
-
def
transformHeaders(f: (Headers) ⇒ Headers): Self
- Definition Classes
- Message
- val uri: Uri
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
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
- Definition Classes
- Message
-
def
withAttributes(attributes: Vault): Self
- Definition Classes
- Message
-
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.- Definition Classes
- Message
-
def
withContentType(contentType: Content-Type): Self
- Definition Classes
- Message
-
def
withContentTypeOption(contentTypeO: Option[Content-Type]): Self
- Definition Classes
- Message
-
def
withEmptyBody: Self
Set an empty entity body on this message, and remove all payload headers that make no sense with an empty body.
Set an empty entity body on this message, and remove all payload headers that make no sense with an empty body.
- Definition Classes
- Message
-
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
- Definition Classes
- Message
-
def
withHeaders(headers: ToRaw*): Self
- Definition Classes
- Message
-
def
withHeaders(headers: Headers): Self
- Definition Classes
- Message
-
def
withHttpVersion(httpVersion: HttpVersion): Self
- Definition Classes
- Message
- def withMethod(method: Method): Request[F]
- def withPathInfo(pi: Path): Request[F]
-
def
withTrailerHeaders(trailerHeaders: F[Headers]): Self
- Definition Classes
- Message
- def withUri(uri: Uri): Request[F]
-
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
- Definition Classes
- Message
-
def
withoutContentType: Self
- Definition Classes
- Message
-
def
withoutTrailerHeaders: Self
- Definition Classes
- Message
Deprecated Value Members
-
def
withBody[T](b: T)(implicit F: Applicative[F], w: EntityEncoder[F, T]): F[Self]
- Definition Classes
- Message
- Annotations
- @deprecated
- Deprecated
(Since version 0.19) Use withEntity
-
def
withPathInfo(pi: String): Request[F]
- Annotations
- @deprecated
- Deprecated
(Since version 0.22.0-M1) Use {withPathInfo(Uri.Path)} instead
-
def
withType(t: MediaType)(implicit F: Functor[F]): Self
- Definition Classes
- Message
- Annotations
- @deprecated
- Deprecated
(Since version 0.20.0-M2) Use withContentType(
Content-Type
(t)) instead