-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpClient] Support invalid Location header #31776
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
Comments
Would you mind sending a PR with the change and a test case please? Please check the result of calling getInfo(redirect_url) |
It's not me who are replying, it is api which works like that, probably to make it works with HEAD request - but I still don't know why someone choose After some research I think it is not fixable without try-catch and rethrow when valid location required, so it is probably not worth implementing for this one edge use case :/ |
I've decided to close this issue, since implementing it is definitely not worth it - I've used plain curl requests for this edge-case and got confirmed what I've been thinking before - http standards should never be broken :) |
I decided to fix it :) |
…ocation header (nicolas-grekas) This PR was merged into the 4.3 branch. Discussion ---------- [HttpClient] Don't throw InvalidArgumentException on bad Location header | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #31776 | License | MIT | Doc PR | - Instead, just stop following redirections and throw a `RedirectionExceptionInterface` as usual when throwing is not disabled. Commits ------- 4acca42 [HttpClient] Don't throw InvalidArgumentException on bad Location header
Symfony version(s) affected: 4.3.0
Description
Curl http client try to parse
Location
header even if no redirects allowed, which makes unable to get response/headers value from endpoint which returns invalid url inLocation
header.How to reproduce
Results in
InvalidArgumentException Malformed URL ...
, no way to use value of this header.Possible Solution
Simply check if we are gonna use
Location
value as redirect target - https://github.com/mleczakm/symfony/commit/5c27013e6b1c8f710821019f1ec64fc29f034d3bThe text was updated successfully, but these errors were encountered: