-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Update HttpStatusCode enum with updates #15650
Comments
Main RFC, with links to update RFCs: https://tools.ietf.org/html/rfc2616 |
RFC2616 is obsolete now. The latest set of HTTP RFCs are 7230 thru 7240: http://tools.ietf.org/html/rfc7230 Also, are you asking for adding new enum values or changing existing ones? We can't change existing ones. And adding new ones would be an API change which we would have to figure out how to get working across all the platforms as well as Desktop. |
cc: @SidharthNabar |
If we make a new enum or type we should also look at the fact that we have our own |
Don't understand why you would have another enum type that is substantially similar to System.Net HttpStatusCode. cc: @ericstj @weshaggard |
What @davidsh said. But if we must have a new one, perhaps it should be more complete? |
I'm fuzzy on the reasons but it might have been a dependency thing? Where are the status codes defined right now? It might have also been a flexibility thing so it was ok to change outside of .NET Framework (since we didn't want to bother unifying the type). |
We chose a different strategy for two reasons:
|
Fine concerns, but to me neither of those seems like enough reason to introduce another type with the same values for the same purpose. (And for the second case, if the first is an enum, then you can do |
Can't change this type because it unifies with .NET Framework right? That's another good reason to make a new one. |
I'm not following why that's a good reason. Why not just add additional values to HttpStatusCode here and then to the desktop implementation the next time it revs? We need to be able to add additional members/etc. to existing framework types, and shouldn't just add a new type every time we want to augment something. In some cases, sure, it makes sense to branch out; this doesn't seem like one of them to me, at least not for the cited reasons. |
@stephentoub Because it forces multi-targeting if anyone wants to use a new enum value. |
Or just using it by number until they're able to upgrade to the newer version of the contract, e.g. |
Or just have one type in a new place that doesn't unify because it's just a class and there's little value (IMO) in unifying this enum. |
This is all getting side-tracked from the real reason we did this; we didn't want the type to be an enum because it's a poor fit for this data set, so we choose const int's instead. |
Actually, it's getting side-tracked because the issue reported here is about missing status codes. 😄 That said, I'll throw in a +1 for the enum over |
@mteper We've been through most of this discussion (also, re: discoverability) at aspnet/HttpAbstractions#345 (comment) |
Thanks @khellang! Funny, I saw that thread back when it was originally discussed and completely forgot about it! FWIW, I'd back your struct-based proposal. Back to the issue at hand, whatever mechanism the .NET folks decide to go with, can we add in the extra codes now, which the bits are still baking? |
Hey, I was wondering what was going on with this? The Windows guys have already created their own copy of the Enum and extended it: https://msdn.microsoft.com/en-us/library/windows/apps/windows.web.http.httpstatuscode?cs-save-lang=1&cs-lang=csharp#code-snippet-1 |
The WinRT Windows.Web.Http.HttpStatusCode was added as part of the larger effort when the WinRT APIs were added. Those types are distinct from the .NET types. They are used for WinRT apps across UWP apps for Windows for C++, C# and JS languages. We still have plans to add enum values for .NET System.Net.HttpStatusCode type. However, it is part of the System.Net.Primitives contract and we need to work out how to rev that contract version and also add those values to .NET Framework (Desktop) since that type lives there as well. |
It shouldn't be very hard to add the new enum values to System.Net.Primitives in netcoreapp1.2 and above. I believe a different issue should be opened to track the discussion regarding adding a new type or unifying with ASP.Net. |
I'd like to request 418 be added too 😈 |
My fave is https://en.wikipedia.org/wiki/HTTP_451 |
@kwaazaar are you interested in tackling the larger enum update? We can help you with the API review if you need guidance ... |
@karelz: do you want me to create the pullrequest for this issue? That's fine, just let me know. |
Actually, my apologies, I spoke up too soon (previous reply deleted to avoid confusion). |
@Caesar1995 can you please prepare the formal API proposal (see the links above - please check latest RFCs as well) |
@Caesar1995 Please also look thru this list (WinRT Windows.Web.Http.HttpStatusCode) and make sure that all values there are included in System.Net.HttpStatusCode revisions. See: https://docs.microsoft.com/en-us/uwp/api/windows.web.http.httpstatuscode |
We can move discussion to: dotnet/corefx#26441 |
I have moved the API proposal to the top post - let's keep this issue as the primary tracking issue - it has upvotes + people interested are already subscribed. |
This needs updating, it's definitely a bug in .NET that it's effectively blind to any HTTP status codes less than about a decade old. It shouldn't require 3 years of wrangling to update a list of HTTP status codes. If it does then maybe we need to consider not using this enum as the only representation of the status code, and update classes like |
TBH, an enum is a very poor choice for an open set in the first place. See aspnet/HttpAbstractions#345 (comment) (mentioned earlier in the thread) 😉 |
Kristian, I like your struct approach better and it would be EXTREMELY cool if code owners read it as well and approve/dismiss it with proper reasoning in this iteration. However, current fear is that it would delay the arrival of missing codes in any shape by another 2-3 years.. so greedily, whatever gets approved lets snatch that first then reiterate 😉 |
Is this actually unironically used that much? |
The existence of a Fool's Day RFC is not a reason to add it. |
Looks like other stacks (Node.js, Go, Python and ASP.NET) already decided to keep it: https://en.wikipedia.org/wiki/Hyper_Text_Coffee_Pot_Control_Protocol |
@KeithHenry are you interested in grabbing the issue and updating your PR dotnet/corefx#26415 with full list approved above? |
I think we should avoid adding 418. The HTTP Working Group has tried hard to get this status code removed from various libraries and languages. A lot of these have decided to keep it around (for now) as it would be a breaking change to remove it. It would be a mistake to add it to .NET now. See golang/go#21326, nodejs/node#14644, psf/requests#4238 and aspnet/HttpAbstractions#915 // @mnot |
Fair, if all the reasons for keeping it in other platforms were only breaking changes with previous versions, we should not add it (I think we can live with difference between ASP.NET codes and .NET codes). I would suggest to keep the line in, commented out with link to why it's left out (keeping context for future). |
Now that it IS in IANA, should it be included? (I honestly don't care either way, but it does have a semi-official status now) |
@SamuelEnglard what should be included in your opinion? |
That's a draft. https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml (last updated 2017-12-20) still says 418 is "Unassigned" 🤔 Anyway, I don't think there's any point in including status codes that are "Reserved":
|
@khellang missed that it's still draft status, thanks for that! As to what to do...
So HTCPCP is related to HTTP/1.1 the same way SPDY, HTTP/2, or even WebSockets are. It's another branch in the family. So if we put HTTP/2 status codes in here HTCPCP status codes can too. |
Why so eager to add a non-standard status code against the HTTP working group's wishes? If you need it in your apps, you can still use it, but I don't think there's any point in adding it to the framework now -- especially since it's sailing up to become a reserved status code (probably before .NET Core 2.1 ships) soon. |
I think 418 should be kept around, just maybe not an HTTP status code (HTCPCP status code I suppose). |
Right. That's a different API proposal - maybe in combination with |
Latest Proposal
We should update current HttpStatusCode to include more official status codes defined in recent RFCs.
Proposed API
Details
Values added from WinRT: Windows.Web.Http.HttpStatusCode:
ImATeapot
MisdirectedRequest
UnavailableForLegalReasons
EarlyHints
Original Proposal
Please update with codes from RFCs 2817, 5785, 6266, 6585.
The text was updated successfully, but these errors were encountered: