Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

WebCmdlets SetRequestContent wrong logic? #18973

Copy link
Copy link
@CarloToso

Description

@CarloToso
Issue body actions

Prerequisites

Steps to reproduce

I was cleaning up the code of WebCmdlets #18964 and I noticed some code that seems incorrect. (WebRequestPSCmdlet.Common.cs lines 1114-1134)

if (content is FormObject form)
                {
                    SetRequestContent(request, form.Fields);
                }
                else if (content is IDictionary dictionary && request.Method != HttpMethod.Get)
                {
                    SetRequestContent(request, dictionary);
                }
                else if (content is XmlNode xmlNode)
                {
                    SetRequestContent(request, xmlNode);
                }
                else if (content is Stream stream)
                {
                    SetRequestContent(request, stream);
                }
                else if (content is byte[] bytes)
                {
                    SetRequestContent(request, bytes);
                }
                else if (content is MultipartFormDataContent multipartFormDataContent)

Expected behavior

`else if (content is IDictionary dictionary && request.Method != HttpMethod.Get)`

It seems this line doesn't set the request.Content if the method is GET and the body is a dictionary

Actual behavior

I think we should have a consistent behaviour for other type of bodys, for form and infile

Should we always set the request.Content, or never do it?

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.1
PSEdition                      Core
GitCommitId                    7.3.1
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.