mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-19 11:19:36 +00:00
A content provider that wrote past the length it was given put the extra bytes after the framed body, where a keep-alive peer read them as the next message. Write only what fits and fail the write, on both the server and the client. Content-Length and Transfer-Encoding a handler set were sent next to the ones the library worked out, for ranges and compression, and a post-routing handler could change the body after Content-Length was set. Work both out in one place, from the body about to be written, again after the post-routing handler; a HEAD response keeps the length its handler gave it. A 1xx, 204 or 304 response sends no body and, following RFC 9110 8.6, no Content-Length. The client still sends a Content-Length or Transfer-Encoding its caller passes, as curl and urllib3 do, and the README says these have to match the body.