Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.2.x] restore streaming in StandaloneWSRequest.stream() (backport #803) by @maxcom #805

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading