Client

org.http4s.client.Client$
See theClient companion trait
object Client

Attributes

Companion
trait
Source
Client.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Client.type

Members list

Value members

Concrete methods

def apply[F[_]](f: Request[F] => Resource[F, Response[F]])(implicit F: MonadCancelThrow[F]): Client[F]

Attributes

Source
Client.scala
def Pull.output[Nothing,A](chunk).>>[F,A,Unit](go(`stream₂`)) })) caseNone=> Pull.done })) StreamPullOps[F,A](go(source)).stream } defprocessResponse(response:Response[F],`disposed₂`:Ref[F,Boolean]):Resource[F,Response[F]]=Resource.eval[F,Channel[F,Chunk[Byte]]](Channel.synchronous[F,Chunk[Byte]](F)).map[Tuple2[Channel[F,Chunk[Byte]],F[Unit]]](((channel:Channel[F,Chunk[Byte]])=>{ valproducer:F[Unit]=monadCancelOps_[F,Unit](response.body.chunks.through[[x>:Nothing<:Any]=>F[x],Nothing](channel.sendAll).compile[[x>:Nothing<:Any]=>F[x],[x>:Nothing<:Any]=>F[x],Any](target[[x>:Nothing<:Any]=>F[x]](forConcurrent[[x>:Nothing<:Any]=>F[x]](F))).drain).uncancelable(F) Tuple2.apply[Channel[F,Chunk[Byte]],F[Unit]](channel,producer) })).flatMap[Response[F]](((`x$1₃`:Tuple2[Channel[F,Chunk[Byte]],F[Unit]])=>(`x$1₃`:@unchecked)match{ caseTuple2(channel,producer)=> Resource.make[F,Fiber[F,Throwable,Unit]](genSpawnOps[F,Unit,Throwable](`producer₂`)(F).start(F))(((p:Fiber[F,Throwable,Unit])=>monadCancelOps_[F,Unit](`channel₂`.stream.compile[[x>:Nothing<:Any]=>F[x],[x>:Nothing<:Any]=>F[x],Chunk[Byte]](target[[x>:Nothing<:Any]=>F[x]](forConcurrent[[x>:Nothing<:Any]=>F[x]](F))).drain).guarantee(toFunctorOps[F,Outcome[F,Throwable,Unit]](p.join)(F).void)(F)))(F).map[Tuple2[Fiber[F,Throwable,Unit],Self]](((`x$1₄`:Fiber[F,Throwable,Unit])=>(`x$1₄`:@unchecked)match{ case$1$=> valr:Self=response.withBodyStream(catsSyntaxIfM[[O>:Nothing<:Any]=>Stream[F,O]](Stream.eval[F,Boolean](`disposed₂`.get))(monadErrorInstance[F](F)).ifM[Byte](Stream.raiseError[F](newIOException("responsewasdisposed"))(fromApplicativeError[F](F)),`channel₂`.stream.unchunks[Byte](refl[Chunk[Byte]]).onFinalize[F](monadCancelOps_[F,Unit](`channel₂`.stream.compile[[x>:Nothing<:Any]=>F[x],[x>:Nothing<:Any]=>F[x],Chunk[Byte]](target[[x>:Nothing<:Any]=>F[x]](forConcurrent[[x>:Nothing<:Any]=>F[x]](F))).drain).guarantee(`disposed₂`.set(true))(F))(F))(monadErrorInstance[F](F))) Tuple2.apply[Fiber[F,Throwable,Unit],Self]($1$,r) })).flatMap[Response[F]](((`x$1₅`:Tuple2[Fiber[F,Throwable,Unit],Self])=>(`x$1₅`:@unchecked)match{ caseTuple2(_,r)=> Resource.onFinalize[F](catsSyntaxIfM[F](`disposed₂`.get)(F).ifM[Unit](F.unit,`r₂`.body.compile[[x>:Nothing<:Any]=>F[x],[x>:Nothing<:Any]=>F[x],Byte](target[[x>:Nothing<:Any]=>F[x]](forConcurrent[[x>:Nothing<:Any]=>F[x]](F))).drain)(F))(F).map[Response[F]](((`x$1₆`:Unit)=>(`x$1₆`:@unchecked)match{ case_=> `r₂` })) })) })) defrun(req:Request[F]):Resource[F,Response[F]]=Resource.eval[F,Ref[F,Boolean]](Ref.apply[F](concurrentInstance[F](F)).of[Boolean](false)).flatMap[Response[F]](((`disposed₃`:Ref[F,Boolean])=>{ valreqAugmented:Request[F]=addHostHeaderIfUriIsAbsolute[F](req.pipeBodyThrough(((`source₂`:Stream[F,Byte])=>until[Byte](`disposed₃`)(`source₂`)))) Resource.eval[F,Response[F]](app.apply(reqAugmented)).onFinalize(`disposed₃`.set(true))(F).flatMap[Response[F]](((_$10:Response[F])=>processResponse(_$10,`disposed₃`))) })) Client.apply[F](((`req₂`:Request[F])=>run(`req₂`)))(F) }" t="n"class="documentableName ">fromHttpApp[F[_]](app: HttpApp[F])(implicit F: Async[F]): Client[F]

Creates a client from the specified HttpApp. Useful for generating pre-determined responses for requests in testing.

Creates a client from the specified HttpApp. Useful for generating pre-determined responses for requests in testing.

Value parameters

app

the HttpApp to respond to requests to this client

Attributes

Source
Client.scala
def liftKleisli[F[_] : MonadCancelThrow, A](client: Client[F]): Client[[_] =>> Kleisli[F, A, _$12]]

This method introduces an important way for the effectful backends to allow tracing. As Kleisli types form the backend of tracing and these transformations are non-trivial.

This method introduces an important way for the effectful backends to allow tracing. As Kleisli types form the backend of tracing and these transformations are non-trivial.

Attributes

Source
Client.scala