-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
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
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
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 dictionaryActual 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.0Visuals
No response
Metadata
Metadata
Assignees
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