Open utterances-bot opened 1 year ago
Note that if you were using symfony/http-client, this would be trivial since the $response->getHeaders()
method does just that: returning the headers when they just arrived. It does follow redirections, is compatible with any retry strategies, and is also able to followup with getting the body of the response just after if that's what you want (something that Guzzle doesn't allow AFAIK).
@nicolas-grekas good tip, thanks!
Wouldn’t it also work to only throw if no “Location” header is present? And/or the status code (not sure that is available) is not 3xx? Would allow Guzzle to still follow redirects and achieve the same effect?
Inspecting HTTP Response Headers Without Downloading Body with Guzzle
Just random stuff.
https://chriswhite.is/coding/inspecting-http-response-headers-without-downloading-body-with-guzzle