amphp / http-client

An advanced async HTTP client library for PHP, enabling efficient, non-blocking, and concurrent requests and responses.

Home Page:https://amphp.org/http-client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

If a response redirects, it sends back raw gzip instead of decoded content

Bilge opened this issue · comments

commented

Somewhere between beta 9 and 11, but probably in beta 11, redirects cause raw gzip instead of decoded content to be emitted in the body.

$client = HttpClientBuilder::buildDefault();
$response = $client->request(new Request('https://steamcommunity.com/profiles/76561197960287930')); // redirects
$body = $response->getBody()->read(); // gzip
$client = HttpClientBuilder::buildDefault();
$response = $client->request(new Request('https://steamcommunity.com/id/GabeLoganNewell/')); // canonical URL (doesn't redirect)
$body = $response->getBody()->read(); // HTML

This is caused by FollowRedirects and DecompressResponse interaction. FollowRedirects copies the headers to the new request. DecompressResponse then thinks the application set the header, so it skips doing anything.