8000 [Feature] Create Headers Only Once and Only If Called · PowerShell/PowerShell@ec28224 · GitHub
[go: up one dir, main page]

Skip to con 8000 tent

Commit ec28224

Browse files
committed
[Feature] Create Headers Only Once and Only If Called
1 parent 03e3257 commit ec28224

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/WebResponseObject.CoreClr.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,28 @@ public Dictionary<string, IEnumerable<string>> Headers
3131
{
3232
get
3333
{
34-
var headers = new Dictionary<string, IEnumerable<string>>(StringComparer.OrdinalIgnoreCase);
35-
foreach (var entry in BaseResponse.Headers)
34+
if(headers == null)
3635
{
37-
headers[entry.Key] = entry.Value;
38-
}
39-
if (BaseResponse.Content != null)
40-
{
41-
foreach (var entry in BaseResponse.Content.Headers)
36+
headers = new Dictionary<string, IEnumerable<string>>(StringComparer.OrdinalIgnoreCase);
37+
foreach (var entry in BaseResponse.Headers)
4238
{
4339
headers[entry.Key] = entry.Value;
4440
}
41+
if (BaseResponse.Content != null)
42+
{
43+
foreach (var entry in BaseResponse.Content.Headers)
44+
{
45+
headers[entry.Key] = entry.Value;
46+
}
47+
}
4548
}
4649

4750
return headers;
4851
}
4952
}
5053

54+
private Dictionary<string, IEnumerable<string>> headers = null;
55+
5156
/// <summary>
5257
/// gets the RelationLink property
5358
/// </summary>

0 commit comments

Comments
 (0)
0