cwhite92 / blog-comments

0 stars 0 forks source link

16-get-headers #5

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

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

nicolas-grekas commented 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).

cwhite92 commented 1 year ago

@nicolas-grekas good tip, thanks!

stayallive commented 1 year ago

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?