Packages

c

lol.http

Response

case class Response(status: Int, content: Content = Content.empty, headers: Map[HttpString, HttpString] = Map.empty, upgradeConnection: (Stream[Task, Byte]) ⇒ Stream[Task, Byte] = _ => Stream.empty) extends FutureLikeResponse with Product with Serializable

An HTTP response.

Represent all the data available in the HTTP response headers, and the response content that can be consumed lazily if needed.

A response can be used to upgrade the HTTP connection to a plain TCP connection. As a server, when you create a response to accept the connection upgrade you must provide this function. It will be called if the client decide to continue and to upgrade the connection. In this case you will receive the upstream as parameter and you have to return the downstream.

If, as a client you receive a 101 response, you can call this function by providing the upstream. In return you will get the downstream.

status

the HTTP response code such as 200 or 404.

content

the response content.

headers

the HTTP headers.

upgradeConnection

a function that will be called to upgrade the connection to a plain TCP connection.

Linear Supertypes
Serializable, Serializable, Product, Equals, FutureLikeResponse, Future[Response], Awaitable[Response], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Response
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. FutureLikeResponse
  7. Future
  8. Awaitable
  9. AnyRef
  10. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Response(status: Int, content: Content = Content.empty, headers: Map[HttpString, HttpString] = Map.empty, upgradeConnection: (Stream[Task, Byte]) ⇒ Stream[Task, Byte] = _ => Stream.empty)

    status

    the HTTP response code such as 200 or 404.

    content

    the response content.

    headers

    the HTTP headers.

    upgradeConnection

    a function that will be called to upgrade the connection to a plain TCP connection.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def addHeaders(headers: (HttpString, HttpString)*): Response

    Add some headers to this response.

    Add some headers to this response.

    headers

    the new headers to add.

    returns

    a copy of the response with the new headers added.

  5. def addHeaders(headers: Map[HttpString, HttpString]): Response

    Add some headers to this response.

    Add some headers to this response.

    headers

    the new headers to add.

    returns

    a copy of the response with the new headers added.

  6. def andThen[U](pf: PartialFunction[Try[Response], U])(implicit executor: ExecutionContext): Future[Response]
    Definition Classes
    Future
  7. def apply[A](content: A)(implicit encoder: ContentEncoder[A]): Response

    Set the content of this response.

    Set the content of this response.

    content

    the content to use for this response.

    encoder

    the ContentEncoder to use to encode this content.

    returns

    a copy of this response with a new content.

  8. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  9. def assertSuccess: Future[Unit]

    Return a successful empty future if the response status is in the Success 2xx range.

    Return a successful empty future if the response status is in the Success 2xx range. Otherwise, it consumes the response as String and report the error as a failed future.

  10. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  11. def collect[S](pf: PartialFunction[Response, S])(implicit executor: ExecutionContext): Future[S]
    Definition Classes
    Future
  12. val content: Content
  13. def drain: Future[Unit]

    Drain the content attached to this response.

    Drain the content attached to this response. It is safe to call this operation even if the stream has already been consumed.

  14. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. def failed: Future[Throwable]
    Definition Classes
    Future
  16. def fallbackTo[U >: Response](that: Future[U]): Future[U]
    Definition Classes
    Future
  17. def filter(p: (Response) ⇒ Boolean)(implicit executor: ExecutionContext): Future[Response]
    Definition Classes
    Future
  18. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  19. def flatMap[S](f: (Response) ⇒ Future[S])(implicit executor: ExecutionContext): Future[S]
    Definition Classes
    Future
  20. def flatten[S](implicit ev: <:<[Response, Future[S]]): Future[S]
    Definition Classes
    Future
  21. def foreach[U](f: (Response) ⇒ U)(implicit executor: ExecutionContext): Unit
    Definition Classes
    Future
  22. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  23. val headers: Map[HttpString, HttpString]
  24. def isCompleted: Boolean
    Definition Classes
    FutureLikeResponse → Future
  25. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  26. def isRedirect: Boolean

    returns

    true is this HTTP response is a redirect.

  27. def map[S](f: (Response) ⇒ S)(implicit executor: ExecutionContext): Future[S]
    Definition Classes
    Future
  28. def mapTo[S](implicit tag: ClassTag[S]): Future[S]
    Definition Classes
    Future
  29. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  30. final def notify(): Unit
    Definition Classes
    AnyRef
  31. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  32. def onComplete[U](f: (Try[Response]) ⇒ U)(implicit executor: ExecutionContext): Unit
    Definition Classes
    FutureLikeResponse → Future
  33. def read[A](effect: (Stream[Task, Byte]) ⇒ Task[A]): Future[A]

    Consume the content attached to this response by evaluating the provided effect function.

    Consume the content attached to this response by evaluating the provided effect function.

    effect

    the function to use to consume the stream.

    returns

    eventually a value of type A.

  34. def readAs[A](implicit decoder: ContentDecoder[A]): Future[A]

    Consume the content attached to this response and eventually produces a value of type A.

    Consume the content attached to this response and eventually produces a value of type A.

    decoder

    the ContentDecoder to use to read the content.

    returns

    eventually a value of type A.

  35. def readSuccess[A](effect: (Stream[Task, Byte]) ⇒ Task[A]): Future[A]

    Consume the content attached to this response by evaluating the provided effect function the status is in the Success 2xx range.

    Consume the content attached to this response by evaluating the provided effect function the status is in the Success 2xx range. Otherwise, it consumes the response as String and report the error as a failed future.

    effect

    the function to use to consume the stream.

    returns

    eventually a value of type A or a failure if the status code was not 2xx.

  36. def readSuccessAs[A](implicit decoder: ContentDecoder[A]): Future[A]

    Consume the content attached to this response if the status is in the Success 2xx range.

    Consume the content attached to this response if the status is in the Success 2xx range. Otherwise, it consumes the response as String and report the error as a failed future.

    decoder

    the ContentDecoder to use to read the content.

    returns

    eventually a value of type A or a failure if the status code was not 2xx.

  37. def ready(atMost: Duration)(implicit permit: CanAwait): Response.this.type
    Definition Classes
    FutureLikeResponse → Awaitable
  38. def recover[U >: Response](pf: PartialFunction[Throwable, U])(implicit executor: ExecutionContext): Future[U]
    Definition Classes
    Future
  39. def recoverWith[U >: Response](pf: PartialFunction[Throwable, Future[U]])(implicit executor: ExecutionContext): Future[U]
    Definition Classes
    Future
  40. def removeHeaders(headerNames: HttpString*): Response

    Remove some headers from this response.

    Remove some headers from this response.

    headerNames

    the header names to remove

    returns

    a copy of the response without the removed headers.

  41. def result(atMost: Duration)(implicit permit: CanAwait): Response
    Definition Classes
    FutureLikeResponse → Awaitable
  42. val status: Int
  43. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  44. def transform[S](f: (Try[Response]) ⇒ Try[S])(implicit executor: ExecutionContext): Future[S]
    Definition Classes
    FutureLikeResponse → Future
  45. def transform[S](s: (Response) ⇒ S, f: (Throwable) ⇒ Throwable)(implicit executor: ExecutionContext): Future[S]
    Definition Classes
    Future
  46. def transformWith[S](f: (Try[Response]) ⇒ Future[S])(implicit executor: ExecutionContext): Future[S]
    Definition Classes
    FutureLikeResponse → Future
  47. val upgradeConnection: (Stream[Task, Byte]) ⇒ Stream[Task, Byte]
  48. def value: Option[Try[Response]]
    Definition Classes
    FutureLikeResponse → Future
  49. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  50. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  51. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  52. final def withFilter(p: (Response) ⇒ Boolean)(implicit executor: ExecutionContext): Future[Response]
    Definition Classes
    Future
  53. def zip[U](that: Future[U]): Future[(Response, U)]
    Definition Classes
    Future
  54. def zipWith[U, R](that: Future[U])(f: (Response, U) ⇒ R)(implicit executor: ExecutionContext): Future[R]
    Definition Classes
    Future

Deprecated Value Members

  1. def onFailure[U](pf: PartialFunction[Throwable, U])(implicit executor: ExecutionContext): Unit
    Definition Classes
    Future
    Annotations
    @deprecated
    Deprecated

    (Since version 2.12.0) use onComplete or failed.foreach instead (keep in mind that they take total rather than partial functions)

  2. def onSuccess[U](pf: PartialFunction[Response, U])(implicit executor: ExecutionContext): Unit
    Definition Classes
    Future
    Annotations
    @deprecated
    Deprecated

    (Since version 2.12.0) use foreach or onComplete instead (keep in mind that they take total rather than partial functions)

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from FutureLikeResponse

Inherited from Future[Response]

Inherited from Awaitable[Response]

Inherited from AnyRef

Inherited from Any

Ungrouped