I've just spent the past 10 hours trying to figure out why my http request was failing when I did a
request.Content.ReadAsMultipartAsync().Result.Contents
It kept returning the error:
Unexpected end of MIME multipart stream. MIME multipart message is not complete.
After many hours of research, I finally discovered that the request did not have an ending CRLF, which apparently .Net needs to determine the end of the request. When I added my own CRLF, everything worked great.
In WireShark, I looked at one of the requests, I saw that the chunked request did have an ending CRLF, but the De-Chunked request did not.
So that leaves me with 2 questions.
- Why is my request missing the ending CRLF, and
- Is there any way to add it back before it gets to .Net so that .Net will process it correctly?
The '0' CRLF CRLF at the end is part of the chunked encoding, and is correctly removed by Wireshark, when giving you the de-chunked data. It looks to me the problem is that the MIME encoding needs its own CRLF in addition to those added by the chunked encoding.
It's hard to say exactly where the problem lies but it looks to me that you might be looking in the wrong place.