Skip to content

Commit

Permalink
deprecatre req and add streamin
Browse files Browse the repository at this point in the history
  • Loading branch information
varshith257 committed Sep 18, 2024
1 parent 46980fd commit 466544c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions zio-http/shared/src/main/scala/zio/http/ZClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ final case class ZClient[-Env, ReqEnv, -In, +Err, +Out](
): ZClient[Env, ReqEnv, In, Err2, Out] =
transform(bodyEncoder.refineOrDie(pf), bodyDecoder.refineOrDie(pf), driver.refineOrDie(pf))

@deprecated("Use `batched` or `streaming` instead", since = "3.0.0")
def request(request: Request)(implicit ev: Body <:< In, trace: Trace): ZIO[Env & ReqEnv, Err, Out] = {
def makeRequest(body: Body) = {
driver.request(
Expand Down Expand Up @@ -238,6 +239,28 @@ final case class ZClient[-Env, ReqEnv, -In, +Err, +Out](
.fold(ZStream.fail(_), f)
}

def streaming(
request: Request,
)(implicit ev: Body <:< In, trace: Trace, ev1: ReqEnv =:= Scope): ZIO[Env & ReqEnv, Err, Out] = {
def makeRequest(body: Body) = {
driver.request(
self.version ++ request.version,
request.method,
self.url ++ request.url,
self.headers ++ request.headers,
body,
sslConfig,
proxy,
)
}
if (bodyEncoder == ZClient.BodyEncoder.identity)
bodyDecoder.decodeZIO(makeRequest(request.body))
else
bodyEncoder
.encode(ev(request.body))
.flatMap(body => bodyDecoder.decodeZIO(makeRequest(body)))
}

def ssl(ssl: ClientSSLConfig): ZClient[Env, ReqEnv, In, Err, Out] =
copy(sslConfig = Some(ssl))

Expand Down

0 comments on commit 466544c

Please sign in to comment.