-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Adding HttpWebRequest to HttpClient Migration Guide #42242
base: main
Are you sure you want to change the base?
Conversation
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.
looks good so far, do you plan to add more complex examples showcasing how to migrate use of certificates or ConnectCallback?
docs/fundamentals/networking/http/httpclient-migrate-from-httpwebrequest.md
Outdated
Show resolved
Hide resolved
docs/fundamentals/networking/http/httpclient-migrate-from-httpwebrequest.md
Outdated
Show resolved
Hide resolved
docs/fundamentals/networking/http/httpclient-migrate-from-httpwebrequest.md
Outdated
Show resolved
Hide resolved
Yes, this is ongoing work and this is on my todo list, and I'll actually add specific links to those sections in Notes section in the table. |
docs/fundamentals/networking/http/httpclient-migrate-from-httpwebrequest.md
Outdated
Show resolved
Hide resolved
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.
I like the examples for specific scenarios, it's very practical. I also like the quick reference tables with the mapping.
Overall, I like the direction here, keep going!
I left some comments, mostly about sample code. I think we should be very careful with the code as people will copy-paste this as-is.
docs/fundamentals/networking/http/httpclient-migrate-from-httpwebrequest.md
Outdated
Show resolved
Hide resolved
docs/fundamentals/networking/http/httpclient-migrate-from-httpwebrequest.md
Outdated
Show resolved
Hide resolved
docs/fundamentals/networking/http/httpclient-migrate-from-httpwebrequest.md
Outdated
Show resolved
Hide resolved
docs/fundamentals/networking/http/httpclient-migrate-from-httpwebrequest.md
Outdated
Show resolved
Hide resolved
docs/fundamentals/networking/http/httpclient-migrate-from-httpwebrequest.md
Outdated
Show resolved
Hide resolved
docs/fundamentals/networking/http/httpclient-migrate-from-httpwebrequest.md
Outdated
Show resolved
Hide resolved
docs/fundamentals/networking/http/httpclient-migrate-from-httpwebrequest.md
Outdated
Show resolved
Hide resolved
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.
Thank you for working on this, it'll be nice to have a common place we can link people to
|
||
# HttpWebRequest to HttpClient Migration Guide | ||
|
||
This document aims to guide developers through the process of migrating from <xref:System.Net.HttpWebRequest>, <xref:System.Net.ServicePoint>, and <xref:System.Net.ServicePointManager> to <xref:System.Net.Http.HttpClient>. The migration is necessary due to the obsolescence of the older APIs and the numerous benefits offered by <xref:System.Net.Http.HttpClient>, including improved performance, better resource management, and a more modern and flexible API design. By following the steps outlined in this document, developers will be able to transition their codebases smoothly and take full advantage of the features provided by <xref:System.Net.Http.HttpClient>. |
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.
While mentioning performance, should we mention that it's not just a "nice to have" bump in perf by migrating?
It's really that their existing WebRequest logic's perf is likely going to completely tank once they move to Core since WebRequest is just a minimal compat layer (e.g. no connection reuse in tons of cases).
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.
I was actually thinking to add a note or warning for this, to make sure that people who reads this doc will be aware of that WebRequest
is compat layer on top of HttpClient
.
| `TransferEncoding` | <xref:System.Net.Http.Headers.HttpRequestHeaders.TransferEncoding> | See: [Example: Set Request Headers](#example-set-request-headers). | | ||
| `UnsafeAuthenticatedConnectionSharing` | No equivalent API | No workaround | | ||
| `UseDefaultCredentials` | No direct equivalent API | See: [Example: Setting SocketsHttpHandler Properties](#example-setting-socketshttphandler-properties). | | ||
| `UserAgent` | <xref:System.Net.Http.Headers.HttpRequestHeaders.UserAgent> | See: [Example: Set Request Headers](#example-set-request-headers). | |
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.
Nit: A bunch of these are for headers that have 1:1 mappings.
It might be easier to follow if those have a separate "For setting headers like MediaType
, Referer
, ... see [Example])".
On the other hand your list is in alphabetical order so maybe that's better 🤷♂️
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.
I'm not sure, I believe having these properties in alphabetical order would be more useful. Because it's much easier to think about something like this: I need to find X property under Y class, so I can check this Z list.
Summary
This is still ongoing effort, created this PR to get early feedback from folks.
Fixes dotnet/runtime#92690
/cc @dotnet/ncl
Internal previews