I have a web application where user can post url to have his file downloaded. I’m using libcurl and I’m checking response Content-Length to enforce file size limit. I’m worried that some carried away server will continue uploading and will eventually fill up all available space and choke my server. Will libcurl abort downloading file if it’s size is greater than Content-Length?
Share
Yes it will (mostly). As the Content-Length field (when used) is how HTTP is used to tell the size of the body of this particular response. An HTTP client cannot read any further than so, as the connection will be kept open and re-used for the next request.
This is basic HTTP 1.1 functionality and you can find the details in RFC7230 and if you want to read curl code, check out the lib/http.c source code for the Content-Length header matching and parsing and then further how the ‘maxdownload’ field is used in lib/transfer.c etc.