Small changes in Webcmdlets#19109
Conversation
| currentUri = new Uri(request.RequestUri, response.Headers.Location); | ||
|
|
||
| // Continue to handle redirection | ||
| using (client = GetHttpClient(handleRedirect)) |
There was a problem hiding this comment.
Good step for #12764 (comment) You could continue...
There was a problem hiding this comment.
I will try to continue, can you give me a more detailed to-do list?
There was a problem hiding this comment.
I laid out there already. The goal is to cache HttpClient/HttpClientHandler in WebSession. These HttpClient/HttpClientHandler cannot be changed after they start. So if a cmdlet is called with modified arguments when there is a WebSession, we have to recreate them. This makes me think that our first step is to move all initialization to BeginProcessing. If it's possible, we can then implement caching.
...t.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
Show resolved
Hide resolved
...t.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
Outdated
Show resolved
Hide resolved
...t.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
Show resolved
Hide resolved
...t.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
Outdated
Show resolved
Hide resolved
...t.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
Show resolved
Hide resolved
| response = GetResponse(client, redirectRequest, handleRedirect); | ||
| } | ||
| using HttpRequestMessage redirectRequest = GetRequest(currentUri); | ||
| response = GetResponse(client, redirectRequest, handleRedirect); |
There was a problem hiding this comment.
Nit: it would great to inspect how we dispose HttpResponseMessage
There was a problem hiding this comment.
I noticed that:
response = GetResponse(client, redirectRequest, handleRedirect);line 1275return GetResponse(client, requestWithoutRange, handleRedirect);line 1309
are doing the same thing, I think they should have similar formatting, which one is better?
To dispose of HttpResponseMessage we could add using on line 1422, and it might be enough
There was a problem hiding this comment.
I don't understand the question about formatting.
To dispose of HttpResponseMessage we could add using on line 1422
Yes. And I see two callsites return GetResponse - I guess we need to dispose previous response before return new one.
In follow PR please.
There was a problem hiding this comment.
I'm sorry, I meant they should have the same syntax (not formatting) . And I wanted to know which syntax was more clear. In the next PR
There was a problem hiding this comment.
I still don't understand. Feel free to pull PR with your preference.
...t.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
Outdated
Show resolved
Hide resolved
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
|
🎉 Handy links: |
PR Summary
PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).