From f34ee754f8b1e28f7ea3edd26571a331bb696085 Mon Sep 17 00:00:00 2001 From: Maxim Valyanskiy Date: Mon, 2 Oct 2023 13:06:05 +0300 Subject: [PATCH] restore streaming in StandaloneWSRequest.stream() (cherry picked from commit 5818e4f0b030e293c525ab47dadf2bc90d48b12c) --- .../api/libs/ws/ahc/StandaloneAhcWSRequest.scala | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/StandaloneAhcWSRequest.scala b/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/StandaloneAhcWSRequest.scala index 8e8816d1..c4724fd6 100644 --- a/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/StandaloneAhcWSRequest.scala +++ b/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/StandaloneAhcWSRequest.scala @@ -49,7 +49,7 @@ case class StandaloneAhcWSRequest( with AhcUtilities with WSCookieConverter { override type Self = StandaloneAhcWSRequest - override type Response = StandaloneAhcWSResponse + override type Response = StandaloneWSResponse require(client != null, "A StandaloneAhcWSClient is required, but it is null") require(url != null, "A url is required, but it is null") @@ -223,8 +223,6 @@ case class StandaloneAhcWSRequest( override def withMethod(method: String): Self = copy(method = method) private val executor: StandaloneAhcWSRequest => Future[Response] = { - import scala.concurrent.ExecutionContext.Implicits.global - lazy val executor = filterWSRequestExecutor(WSRequestExecutor { case ahcReq: StandaloneAhcWSRequest => client.execute(ahcReq.buildRequest()) @@ -234,9 +232,7 @@ case class StandaloneAhcWSRequest( }) { (req: StandaloneAhcWSRequest) => - executor(req).collect { case resp: StandaloneAhcWSResponse => - resp - } + executor(req) } } @@ -246,7 +242,13 @@ case class StandaloneAhcWSRequest( filters.foldRight(next)((filter, executor) => filter.apply(executor)) } - override def stream(): Future[Response] = executor(this) + override def stream(): Future[Response] = { + val executor = filterWSRequestExecutor(WSRequestExecutor { request => + client.executeStream(request.asInstanceOf[StandaloneAhcWSRequest].buildRequest()) + }) + + executor(this) + } /** * Returns the HTTP header given by name, using the request builder. This may be signed,