-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Improve IFormCollection.Items documentation #44372
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
@Tratcher GTG? |
/// </para> | ||
/// <para> | ||
/// Invoking this property could result in thread exhaustion since it's wrapping an asynchronous implementation. | ||
/// To prevent this the method <see cref="Microsoft.AspNetCore.Http.Features.FormFeature.ReadFormAsync" /> can be used. |
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 doesn't seem to like your ReadFormAsync reference.
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
/azp run |
Commenter does not have sufficient privileges for PR 44372 in repo dotnet/aspnetcore |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
@JamesNK Do you still have concerns? |
@sebastienros James might appreciate it if the tests were green before he gave his sign-off. 😉 |
/// <remarks> | ||
/// <para> | ||
/// Invoking this property could result in thread exhaustion since it's wrapping an asynchronous implementation. | ||
/// To prevent this the method <see cref="ReadFormAsync" /> can be used. |
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.
/// To prevent this the method <see cref="ReadFormAsync" /> can be used. | |
/// To prevent this the method <see cref="ReadFormAsync(CancellationToken)"/> can be used. |
I think this should do it?
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.
Why do you need the parameter list if there's only one overload? It seems to work without in local tests.
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.
Oh, I see, it was supposed to be the one in src/Http/Http.Features/src/IFormCollection.cs, not in this file. Yes, either add (CancellationToken)
or remove ()
.
Co-authored-by: Safia Abdalla <[email protected]>
/// </para> | ||
/// <para> | ||
/// Invoking this property could result in thread exhaustion since it's wrapping an asynchronous implementation. | ||
/// To prevent this the method <see cref="HttpContext.Request.ReadFormAsync()" /> can be used. |
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.
ReadFormAsync()
returns this type (IFormCollection
) at which point using this indexer is expected, so I don't think this warning belongs here. I think the warning on HttpRequest.Form
is sufficient. We could also add it to IFormFeature.Form
. It looks like IFormFeature.ReadForm()
already has a similar warning, but we could update it to match.
Co-authored-by: James Newton-King <[email protected]>
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.
Fix cref
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.
Fix cref II
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.
Http.Features doesn't have a reference to HttpRequest!
Co-authored-by: James Newton-King <[email protected]>
Source code generators are almost easier to code |
I just noticed Stephen's feedback:
I agree that the warning shouldn't be here. IFormCollection is already in memory. Using an indexer on it isn't blocking. |
@@ -101,11 +101,10 @@ public IFormCollection ReadForm() | |||
|
|||
if (!HasFormContentType) | |||
{ | |||
throw new InvalidOperationException("Incorrect Content-Type: " + _request.ContentType); | |||
throw new InvalidOperationException("This request does not have a Content-Type header. Forms are available from requests with bodies like POSTs and a form Content-Type of either application/x-www-form-urlencoded or multipart/form-data."); |
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 request does not have a Content-Type header.
I think this is not correct, request can have a Content-Type
header but maybe not the correct/expected ones, so I liked the previous version with Incorrect
more. Maybe Missing or incorrect Content-Type header.
?
I personally liked having the actual Content-Type
in the exception message as well: _request.ContentType
.
Should this also be updated?
https://github.com/dotnet/aspnetcore/pull/44372/files#diff-6c007cfec0e65e3cfcda8478b356cfae73205755d7a3fde70fe101acedee2533R136
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
Fixes #36712
I might have too many details in this comment, but at least the reviewers will have all the pieces to suggest what should go where.