Skip to content

Commit

Permalink
Merge pull request #805 from playframework/mergify/bp/2.2.x/pr-803
Browse files Browse the repository at this point in the history
[2.2.x] restore streaming in StandaloneWSRequest.stream() (backport #803) by @maxcom
  • Loading branch information
mergify[bot] authored Oct 4, 2023
2 parents 15cbd8e + f34ee75 commit 7544694
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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())
Expand All @@ -234,9 +232,7 @@ case class StandaloneAhcWSRequest(
})

{ (req: StandaloneAhcWSRequest) =>
executor(req).collect { case resp: StandaloneAhcWSResponse =>
resp
}
executor(req)
}
}

Expand All @@ -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,
Expand Down

0 comments on commit 7544694

Please sign in to comment.