mirror of
https://github.com/swift-server/async-http-client.git
synced 2026-05-03 07:32:29 +00:00
ba1d03d8d1
Add a configuration option to retain the HTTP method and body receiving 301 or 302 responses. Currently we automatically change the method to GET, and remove the body, before following a 301 or 302. This is compliant with the fetch specification: https://fetch.spec.whatwg.org/#http-redirect-fetch However, it is useful to be able to override this behaviour and retain the method and body. Changes - Add a new struct to encapsulate the (now 4) arguments of the follow case of the redirect mode - Add new options `retainHTTPMethodAndBodyOn301` and `retainHTTPMethodAndBodyOn302`. Defaults to false because thats the existing behaviour today - When it is true, do not convert requests to GET after following a redirect - Note: this does not affect 307/308 (or any other) redirects. They always preserve their method --------- Co-authored-by: Fabian Fett <fabianfett@apple.com>