-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebAPI: Treat the args dictionary as immutable #995
Conversation
} | ||
|
||
|
||
var urlBuilder = new StringBuilder(); | ||
var paramBuilder = new StringBuilder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is HttpValueCollection
only in ASP? If .NET's uri/querystring stuff can be used, all this custom escaping code could be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to be an internal class only in both .NET Framework and Core, and does not appear as an available API anywhere on MS docs site. HttpUtility can parse but not build. FormUrlEncoded content can build but it requires having a full IEnumerable of all the values upfront, and is async.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's lame.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR follows on from #992 by avoiding making any changes to the arguments dictionary in the first place.
I've rewritten the flow of the HTTP request builder function so that instead of updating the dictionary and then transforming the dictionary into text, we write out the text values directly, and then copy over the existing dictionary values.
cc/ @JustArchi @xPaw