Skip to content

Feature Request: create switch to persist HTTP method when following a redirect for Invoke-RestMethod or Invoke-WebRequest #14531

@codaamok

Description

@codaamok

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 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions