-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Summary of the new feature/enhancement
This request is for a parameter which persists the original HTTP method used in Invoke-RestMethod and Invoke-WebRequest upon redirect. Currently, when the client receives a redirect from the web server, the HTTP client used by said cmdlets reissues the HTTP call but persistently uses HTTP GET, regardless what method was originally used.
This is typical to how browsers operate, and it's also how cURL operates out of the box, too.
Here is an example:
Invoke-RestMethod -Uri "http://test.acook.io" -Method POSTThe web server will redirect the request to https:// and process index.php which just prints out $_SERVER['REQUEST_METHOD'] (link)
Proposed technical implementation details (optional)
A parameter that instructions the cmdlets to persist the originally intended HTTP method through redirects would be useful in scenarios where the web server issues a 30x redirect of http:// to https://.
cURL offers this parameter idea, but for just POST methods, via --post301, --post302 and --post303.
Ideally, this request is to have a switch which persists all types of HTTP methods through redirects via said cmdlets.