-
-
Notifications
You must be signed in to change notification settings - Fork 214
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
Content-Type multipart/form-data is not seen as byte[] anymore #248
Comments
Which version are you using now ? 1.0.6 ? |
It only works with version 1.0.4.17. I tested all the other versions from 1.0.4.18 upto 1.0.6 and I have the issue |
In version 1.0.4.17, you can see in the BodyParser class that a test is done on the ContentType header before trying to read the body as string (from line 50):
|
from version 1.0.4.18, the code doesn't check the content type anymore before trying reading body as string:
|
Yes I see. |
See PR |
I don't understand what you are going to do by saying "add multipart". Putting back the tests? In fact multipart MUST be seen as binary and NOT string... Otherwise any byte "zero" in the body content will stop the reading of the body. The body must be read as byte[] and not string.... |
I checked your fix. Indeed it's a shortcut. And it should work. But putting back the tests as before is not more backward compatible ? |
I'm ready to validate this new version when available. I'll keep you posted... |
"add multipart" --> I mean just fixing this code to support your test scenario. |
|
The content-type is the key element to decide how to read the body. Trying reading the body as string without checking that the content type is of "text" type can be an issue sometime... no ? I think the way it was done in version 1.4.0.17 is safe. Any special case that needed to remove those checks ? Also in the content-type info you can have the encoding to properly read the body... |
By that time I changed the code for parsing from the body. For your specific case, it looks like a work-around yes. |
In fact the property DetectedBodyTypeFromContentType is not used afterward (but only is your fix right now for the multipart). I think a test must be added based on that value just before the "try" statement for string/json. |
notion of "breaking change" ;-) In fact since 1.0.4.18 it was a breaking change ;-) Let's wait indeed for more usecases to see if more changes are needed. Any info about release time for this version 1.0.6.1? |
really appreciate your reactivity! Thanks a lot again! |
In a few minutes, the 1.0.6.1`NuGet will be visible. |
I did some tests and all seems to work fine! Good job! Thanks a lot! |
Since version 1.0.4.18, if the request body is of content-type "multipart/form-data", it is seen as string body instead of byte body. Bug seems to be in the BodyParser class where the content-type is not check anymore before trying reading the content as string. Before version 1.0.4.18, a check was done to see if the content is of "text" type before trying to convert body to string. Our MultipartMatcher implementation cannot work anymore because of this.
The text was updated successfully, but these errors were encountered: