Feature Request: create switch to persist HTTP method when following a redirect for Invoke-RestMethod or Invoke-WebRequest
See original GitHub issueSummary 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 POST
The 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.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11
Top GitHub Comments
@codaamok Thanks! Now I see you want a flexibility if a server sends 301 or 302 (I am not sure about 303) wrong status instead of 307 one. I agree it could be useful and I agree to mentor implementation but we need more detail proposal (one parameter? some?) and more feedback.
🎉This issue was addressed in #18894, which has now been successfully released as
v7.4.0-preview.2
.🎉Handy links: