Trait/Object

lol.http

Client

Related Docs: object Client | package http

Permalink

trait Client extends Service

An HTTP client.

val eventuallyContent = client(Get("/hello")).flatMap { response =>
  response.readAs[String]
}

An HTTP client is a Service function. It handles HTTP requests and eventually returns HTTP responses.

A client maintains several TCP connections to the remote server. These connections are used to send requests and are blocked until the corresponding response has been received. If no connection is available when a new request comes, it waits for connectionTimeout time for one connection to become available.

It is important that the user code completly consumes the response content stream, so the connection is freed for the next request. That's why it is better to use the run operation if possible since this one automatically drains the request upon return.

If the request to execute does not specify an Host header, it will be automatically added and set to the value of the client host.

Linear Supertypes
(Request) ⇒ Future[Response], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Client
  2. Function1
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def connectionTimeout: FiniteDuration

    Permalink

    The maximum amount of time a request will wait to obtain an HTTP connection.

  2. implicit abstract def executor: ExecutionContext

    Permalink

    The ExecutionContext that will be used to run the user code.

  3. abstract def host: String

    Permalink

    The host this client is connected to.

  4. abstract def maxConnections: Int

    Permalink

    The maximum number of TCP connections maintained with the remote server.

  5. abstract def options: ClientOptions

    Permalink

    The client options such as the number of IO thread used.

  6. abstract def port: Int

    Permalink

    The TCP port this client is connected to.

  7. abstract def scheme: String

    Permalink

    The scheme used by this client (either HTTP or HTTPS if connected in SSL).

  8. abstract def ssl: Configuration

    Permalink

    The SSL configuration used by the client.

    The SSL configuration used by the client. Must be provided if the server certificate is not recognized by default.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def andThen[A](g: (Future[Response]) ⇒ A): (Request) ⇒ A

    Permalink
    Definition Classes
    Function1
    Annotations
    @unspecialized()
  5. def apply(request: Request, followRedirects: Boolean, timeout: FiniteDuration = FiniteDuration(30, "seconds")): Future[Response]

    Permalink

    Send a request to the server and eventually give back the response.

    Send a request to the server and eventually give back the response.

    request

    the HTTP request to be sent to the server.

    followRedirects

    if true follow the intermediate HTTP redirects.

    timeout

    maximum amount of time allowed to retrieve the response.

    returns

    eventually the HTTP response.

  6. def apply(request: Request): Future[Response]

    Permalink

    Send a request to the server and eventually give back the response.

    Send a request to the server and eventually give back the response.

    request

    the HTTP request to be sent to the server.

    returns

    eventually the HTTP response.

    Definition Classes
    Client → Function1
  7. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  8. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. def compose[A](g: (A) ⇒ Request): (A) ⇒ Future[Response]

    Permalink
    Definition Classes
    Function1
    Annotations
    @unspecialized()
  10. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  14. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  15. def isClosed: Boolean

    Permalink

    Check if this client is already closed (ie.

    Check if this client is already closed (ie. it does not accept any more requests).

  16. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  17. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  18. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  19. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  20. def openedConnections: Int

    Permalink

    The number of TCP connections currently opened with the remote server.

  21. def run[A](request: Request, followRedirects: Boolean = true, timeout: FiniteDuration = FiniteDuration(30, "seconds"))(thunk: (Response) ⇒ Future[A] = ...): Future[A]

    Permalink

    Send this request to the server, eventually run the given function and return the result.

    Send this request to the server, eventually run the given function and return the result. This operation ensures that the response content stream is fully read even if the provided user code do not consume it. The response is drained as soon as the f function returns.

    request

    the HTTP request to be sent to the server.

    followRedirects

    if true follow the intermediate HTTP redirects. Default to true.

    timeout

    maximum amount of time allowed to retrieve the response and extract the return value.

    thunk

    a function that eventually receive the response and transform it to a value of type A.

    returns

    eventually a value of type A.

  22. def runAndStop[A](thunk: (Client) ⇒ Future[A]): Future[A]

    Permalink

    Run the given function and close the client.

    Run the given function and close the client.

    thunk

    a function that take a client and eventually return a value of type A.

    returns

    eventually a value of type A.

  23. def stop(): Future[Unit]

    Permalink

    Stop the client and kill all current and waiting requests.

    Stop the client and kill all current and waiting requests.

    returns

    a Future resolved as soon as the client is shutdown.

  24. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  25. def toString(): String

    Permalink
    Definition Classes
    Client → Function1 → AnyRef → Any
  26. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from (Request) ⇒ Future[Response]

Inherited from AnyRef

Inherited from Any

Ungrouped