File tree Expand file tree Collapse file tree 3 files changed +95
-0
lines changed
src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet Expand file tree Collapse file tree 3 files changed +95
-0
lines changed Original file line number Diff line number Diff line change @@ -1157,6 +1157,9 @@ internal virtual void FillRequestStream(HttpRequestMessage request)
1157
1157
1158
1158
switch ( content )
1159
1159
{
1160
+ case FormObject form :
1161
+ SetRequestContent ( request , form . Fields ) ;
1162
+ break ;
1160
1163
case IDictionary dictionary when request . Method != HttpMethod . Get :
1161
1164
SetRequestContent ( request , dictionary ) ;
1162
1165
break ;
Original file line number Diff line number Diff line change
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ using System . Collections . Generic ;
5
+
6
+ namespace Microsoft . PowerShell . Commands
7
+ {
8
+ /// <summary>
9
+ /// FormObject used in HtmlWebResponseObject.
10
+ /// </summary>
11
+ public class FormObject
12
+ {
13
+ /// <summary>
14
+ /// Gets the Id property.
15
+ /// </summary>
16
+ public string Id { get ; }
17
+
18
+ /// <summary>
19
+ /// Gets the Method property.
20
+ /// </summary>
21
+ public string Method { get ; }
22
+
23
+ /// <summary>
24
+ /// Gets the Action property.
25
+ /// </summary>
26
+ public string Action { get ; }
27
+
28
+ /// <summary>
29
+ /// Gets the Fields property.
30
+ /// </summary>
31
+ public Dictionary < string , string > Fields { get ; }
32
+
33
+ /// <summary>
34
+ /// Initializes a new instance of the <see cref="FormObject"/> class.
35
+ /// </summary>
36
+ /// <param name="id"></param>
37
+ /// <param name="method"></param>
38
+ /// <param name="action"></param>
39
+ public FormObject ( string id , string method , string action )
40
+ {
41
+ Id = id ;
42
+ Method = method ;
43
+ Action = action ;
44
+ Fields = new Dictionary < string , string > ( ) ;
45
+ }
46
+
47
+ internal void AddField ( string key , string value )
48
+ {
49
+ if ( key is not null && ! Fields .
8000
span>TryGetValue ( key , out string test ) )
50
+ {
51
+ Fields [ key ] = value ;
52
+ }
53
+ }
54
+ }
55
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ using System ;
5
+ using System . Collections . ObjectModel ;
6
+
7
+ namespace Microsoft . PowerShell . Commands
8
+ {
9
+ /// <summary>
10
+ /// FormObjectCollection used in HtmlWebResponseObject.
11
+ /// </summary>
12
+ public class FormObjectCollection : Collection < FormObject >
13
+ {
14
+ /// <summary>
15
+ /// Gets the FormObject from the key.
16
+ /// </summary>
17
+ /// <param name="key"></param>
18
+ /// <returns></returns>
19
+ public FormObject this [ string key ]
20
+ {
21
+ get
22
+ {
23
+ FormObject form = null ;
24
+ foreach ( FormObject f in this )
25
+ {
26
+ if ( string . Equals ( key , f . Id , StringComparison . OrdinalIgnoreCase ) )
27
+ {
28
+ form = f ;
29
+ break ;
30
+ }
31
+ }
32
+
33
+ return form ;
34
+ }
35
+ }
36
+ }
37
+ }
You can’t perform that action at this time.
0 commit comments