Based on the HTTP Request Method and Headers, a HTTP server has to determine whether or not to expect a Message Body after the closing CRLFCRLF of the HTTP Request Headers, and also when it does expect one, how many bytes long it is.
How is this calculation made? By what function of the request method and headers can we calculate the length of the request message body.
Followup:
So the HTTP server after parsing the header can simply do the following:
size_t RequestMessageBodyLength()
{
if (RequestHeaderExists("Content-Length"))
return RequestHeaderValue("Content-Length");
else
return 0;
}
Are there corner cases not covered by the above?
(I expect not, the case of the HEAD request is only for the response, not the request)