Some HTTP methods, such as POST
, require a body to be sent after the headers and the double CRLF
.
Others, such as GET
, do not have a body, and for them the double CRLF
marks the end of the request.
But what about others: PUT
, DELETE
, ... how to know which one requires a body?
How should a generic HTTP client react to an unknown HTTP method? Reject it? Require a body by default, or not require a body by default?
A pointer to the relevant spec would be appreciated.
Edit : I'll detail a bit more my question, as asked in the comments.
I'm designing a generic HTTP client that a programmer can use to send arbitrary HTTP requests to any server.
The client could be used like this (pseudo-code):
HttpClient.request(method, url [, data]);
The data is optional, and can be raw data (string), or an associative array of key/value pairs.
The library would url-encode the data if it's an array, then either append the data to the URL for a GET
request, or send it in the message body for a POST
request.
I'm therefore trying to determine whether this HttpClient must/should/must not/should not include a message-body in the request, given the HTTP method chosen by the developer.