-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Adding nullable type functionality for HttpRequest Context Type #32203
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
Conversation
…cAPI.Unshipped.txt to reflect change to nullable type.
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.
The build shows two usages of this property that also need updating, DefaultHttpRequest and HttpLoggingMiddleware.
Looks like a couple places need to react to the nullability addition: |
Good, this fix found a bug in the logging middleware (@jkotalik). MediaTypeHelpers.TryGetEncodingForMediaType should allow
|
…y ToString function.
…gForMediaType function.
I am currently unable to figure out how to apply the TryParse. I see the MediaTypeHeaderValue has a method for it, but can't quite get it to work. I'll go ahead with the other fixes. |
I think this is what you were referring to: When I added that, I received a build error that line 33 would be exposed to the possibility of a null value. And I didn't want to interfere with that logic or implementation.
|
This implementation might work, but I am not sure this is what you are going for, or what you want to do with the null value: if (!MediaTypeHeaderValue.TryParse(contentType, out var mediaType)) |
That's what I had in mind. It avoids throwing for null, empty, or bad contentTypes. |
…EncodingForMediaType. If true, continues through Encoding process.
Hello @Tratcher! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
Thanks @KellenCarl! Announcement: aspnet/Announcements#444 (comment) |
Thank you @Tratcher! I appreciate all the help and feedback! |
Hi @KellenCarl. It looks like you just commented on a closed PR. The team will most probably miss it. If you'd like to bring something important up to their attention, consider filing a new issue and add enough details to build context. |
…icAPI.Unshipped.txt to reflect change to nullable type.
PR Title
Adding nullability annotation on HttpRequest.ContentType
PR Description
Added "?" to make type string nullable for ContentType. Updated PublicAPI.Unshipped.txt to reflect change. I know there is at least one implementation error, but wanted to let code owners make decisions, provide feedback.
Addresses #32097