Closed DGuidi closed 5 years ago
ok, I've made a super-simple test Multipart.zip and all looks ok, so I need to check somehow in my code...
ok, for anyone interested I've found the problem.
basically I logged all requests using an hook in pipelines.BeforeRequest.AddItemToStartOfPipeline(cx =>
with a code that in nancy2 uses RequestStream body = RequestStream.FromStream(request.Body);
, a change respect to nancy1.4 RequestStream body = request.Body;
In some cases I need to reset the stream using stream.Seek(0. SeekOrigin.Begin)
to let the stream valid for subsequent processes, but RequestStream.Seek looks not reset stream.
Using request.Body.Seek(0, SeekOrigin.Begin)
fixes the behavior
Prerequisites
DEBUG
andRELEASE
modeDescription
I'm trying to handle a multipart/form-data request made with postman using nancy 2.0 clinteastwood and .net core 2.1. I'm writing this because I've moved to netcore a code that worked in netfw 4.7.1 and nancy 1.4, so to me this looks a modified behavior.
Anyway I've written a test like this, that uses nancy.testing:
and this code works as expected.
This is my code that handles the request:
Code for MultipartHelper is taken from this issue but I've tested similar code found in blogposts with same results.
Then, I make the same request using postman and using my actual webapp, and basically the same code that works using unittest now throws a BadRequestException because boundaries (from my code) is an empty collection.
See also attached fiddler requests made from: postman browser via fetch