We have started encountering an issue since this weekend just gone. We send a file from an application on one server to an API on another.
Usually this API sits behind cloudflare's CDN/proxy, however since February 13th at around 01:00-02:00 this functionality only works without cloudflare proxying/CDN enabled (we've actually left it enabled but instead edited the host file of the sender to point to our real IP address, not cloudflare's). If we remove the sender application and use postman, the result is the same (using cdn fails, going direct works).
I have a ticket raised with their support, but I also wanted to sanity check this is not potentially something we have done incorrectly.
[HttpPost]
[Route("sendvideofile")]
public async Task<CameraResponse> ReceiveVideoFile()
{
var content = await GetMultipartContent(this.Request.Content).EscapeContext();
var stream = await content.ReadAsStreamAsync().EscapeContext();
return CameraResponse.Create(true);
}
This is our GetMultiPartContent method:
private static async Task<HttpContent> GetMultipartContent(HttpContent requestContent)
{
var filesReadToProvider = await requestContent.ReadAsMultipartAsync().EscapeContext();
return filesReadToProvider.Contents.FirstOrDefault();
}
The exception thrown is:
Message:An error has occurred.
ExceptionMessage:Unexpected end of MIME multipart stream. MIME multipart message is not complete.
ExceptionType:System.IO.IOException
StackTrace: at System.Net.Http.Formatting.Parsers.MimeMultipartBodyPartParser.<ParseBuffer>d__0.MoveNext()
at System.Net.Http.HttpContentMultipartExtensions.<MultipartReadAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Net.Http.HttpContentMultipartExtensions......
As you can see our code is quite simple in reality (I've cut some other proprietary service calls out which won't be causing this), but I am struggling to believe that Cloudflare could have rolled something out that caused base methods in dotnet framework to fail being able to read multipart streams. Or at least if they had, we would have heard about it or been told via our ticket.