This repository has been archived by the owner on Jan 24, 2021. It is now read-only.
Large content length uploads (>32 bit) are loaded into memory, rather than using fs cache #2983
Open
5 of 8 tasks
Prerequisites
DEBUG
andRELEASE
modeDescription
When uploading a large file using Nancy (>2GB) I get a "Stream was too long" error as it looks like the entire upload request stream is attempting to be loaded into memory.
I've narrowed this down to the NancyMiddleware class, ExpectedLength method. It's has a
long
return type but is parsing the content length string usingint
:This cannot parse a
long
value and returnsnull
, which passes an expected length of0
toRequestStream
which causes it to try to read the whole upload stream into memory.I'm not sure if this is intentional or just overlooked, but I figured I would raise an issue before opening a pull request. Checking out Nancy locally and building with
long.TryParse
works correctly (despite being slow).Steps to Reproduce
Run a Nancy sample app.
POST a > 2GB file to any endpoint.
Get 500 response and see "Stream was too large" error in console.
System Configuration
Running in Visual Studio 2019 and uploading a 4gb file with postman (doesn't currently support chunked transfer encoding).
The text was updated successfully, but these errors were encountered: