-
Notifications
You must be signed in to change notification settings - Fork 353
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
JsonMediaTypeFormatter doesn't work when Request is chunked #197
Comments
I seem to remember an issue with chunking that may have been fixed recently. Which ASP.NET version are you using? And, which host e.g. IIS are you testing with? |
I tried with the latest version, 5.2.6 |
Which host? A repro project, preferrably hosted in a GitHub repo, may help. |
@dougbu , the repro is here: https://github.com/felipepessoto/AspNetWebStack_197 The workaround is in Global.asax. To reproduce you can use the ChunkedRequest.raz file with Fiddler, or create a request like this: Headers:
Body:
Be aware of the two line breaks in the end of body. Thanks |
This issue looks like a holdover from HTTP 1.0. The code in this repo special cases The relevant HTTP 1.1 text is in https://tools.ietf.org/html/rfc2616#section-4.3:
So, a chunked message containing @danroth27 @mkArtakMSFT this looks like a straight-up bug in our formatters (again, not just PS. Where our code handles messages with both |
No, there's no support for Transfer-Encoding: gzip. (it would be Content-Length vs Chunked should be a non-issue for high level components like formatters. Only the server should need to worry about the distinction. |
What about the case where the formatters are used in a client application? Separately, I looked again and the |
On the client side as well, it's not the formatters job to validate content-length vs chunked. At most when they're generating a body they could avoid setting both. |
@Tratcher looks like something at a lower level than our web host adds This happens whether or not the request has a non-empty body. Tested using Fiddler, with the following request bodies:
and
|
@felipepessoto the workaround described is incorrect because it unconditionally resets a |
Yeah, I implemented it using a different approach in my real project, deriving from JsonMediaTypeFormatter and looking the headers. This gist is what many people are using though, because it is what you found in stackoverflow when search for this problem That's why I think it is important to fix it instead of workaround it. PS: if I remember well, the same IF exists in XML formatter as well |
Thanks for the investigation, @dougbu! |
Let's look at the repro together next week. We should be able to narrow down the layering quickly. |
Removing Alternate fix of changing the |
Note we went with the "alternate fix" I mentioned earlier, avoiding sync I/O |
The next release will include this fix? Do you already have an approximate release date? Thanks |
The next release will include this fix. @danroth27 have we announced a specific date for 3.2.7? |
When the request transfer-encoding is chunked, the request.ContentLength is 0 instead of null, then JsonMediaTypeFormatter return the default value (null for classes) in this line:
AspNetWebStack/src/System.Net.Http.Formatting/Formatting/BaseJsonMediaTypeFormatter.cs
Line 209 in 1a987f8
The workaround is: https://gist.github.com/jayoungers/0b39b66c49bf974ba73d83943c4b218b but it is just a workaround, and we don't know if it breaks other scenarios.
The text was updated successfully, but these errors were encountered: