I am currently developing a HTTP server application, and I am struggling with the size of body payloads.
According to the spec (and also What's the “Content-Length” field in HTTP header?), the HTTP header Content-Length
contains the actual number of bytes of the whole body payload.
Now, say I'm firing this:
curl --header "Content-Type: text/plain" --request POST --data 'test' http://localhost:5555/
my server will receive a Content-Length
header which contains the value 4
. Since I am sending a string, and the string including null-byte will have 5 bytes, I would expect the Content-Length
to be 5
, and the request body to contain the null-byte as well.
Is my assumption wrong? Or is this some kind of curl issue? I tried with another tool (Paw on Mac), which actually has the option of sending text payloads, with the same result.