Skip to content

Commit

Permalink
Merge pull request #803 from maxcom/streaming-fix
Browse files Browse the repository at this point in the history
restore streaming in StandaloneWSRequest.stream()
  • Loading branch information
mkurz authored Oct 4, 2023
2 parents 9b78193 + 5818e4f commit 0e65ae9
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 0e65ae9

Please sign in to comment.