There seems to be a problem when attempting to pass EmptyBodyStream as body to HTTP requests:
(newBrowser())
->requestStreaming("GET", "https://stackoverflow.com", [], new \React\Http\Io\EmptyBodyStream())
->then(var_dump(...)); // never get's triggeredWhereas, empty resource works just fine:
(newBrowser())
->requestStreaming("GET", "https://stackoverflow.com", [], newReadableResourceStream(tmpfile()))
->then(var_dump(...));I have tried other servers (URLs) as well, and for some of them I get a response immediatelly, for some there is a 10s delay. Maybe the socket isn't being closed when using EmptyBodyStream?
The full example (reason I care) is that I though this would work as a simple HTTP proxy:
$browser = newBrowser();
$browser = $browser->withRejectErrorResponse(false);
$server = newHttpServer(
newStreamingRequestMiddleware(),
fn(ServerRequestInterface$req) => $browser
->requestStreaming($req->getMethod(), TARGET_URL, [], $req->getBody())
->then(fn(ResponseInterface$res) => newResponse($res->getStatusCode(), [], $res->getBody())),
);
But it only works for requests with non-empty bodies. Otherwise $req->getBody() is EmptyBodyStream and the requests get stuck.
There seems to be a problem when attempting to pass
EmptyBodyStreamas body to HTTP requests:Whereas, empty resource works just fine:
I have tried other servers (URLs) as well, and for some of them I get a response immediatelly, for some there is a 10s delay. Maybe the socket isn't being closed when using
EmptyBodyStream?The full example (reason I care) is that I though this would work as a simple HTTP proxy:
But it only works for requests with non-empty bodies. Otherwise
$req->getBody()isEmptyBodyStreamand the requests get stuck.