Should Raxx.set_body/2 raise an error if method is :GET?
It is not standard to send a body with a GET request, or to send a GET request with a content-length.
However I have not yet been able to find anywhere in rfc7230 or rfc7540 that forbids either sending a body or setting a content-length on a get request.
HTTPoison will happily send a GET request with a content-length header, but no body.
Cowboy will happily read the content-length header on the request and take the appropriate amount of body from the TCP stream.
This came up in a bug were we had a helper to add JSON to a request. in the case of no body an assumption was made that the body would be an empty map. This serializes to {} and so a content-length of two was set. But no body was sent. This surfaced as # Phoenix.Router.NoRouteError at ST /api/payment_requests\n\n(the POST request had the first two characters counted as part of previous request)
Should
Raxx.set_body/2
raise an error if method is:GET
?It is not standard to send a body with a GET request, or to send a GET request with a content-length. However I have not yet been able to find anywhere in rfc7230 or rfc7540 that forbids either sending a body or setting a content-length on a get request.
HTTPoison will happily send a GET request with a content-length header, but no body. Cowboy will happily read the content-length header on the request and take the appropriate amount of body from the TCP stream.
This came up in a bug were we had a helper to add JSON to a request. in the case of no body an assumption was made that the body would be an empty map. This serializes to
{}
and so a content-length of two was set. But no body was sent. This surfaced as# Phoenix.Router.NoRouteError at ST /api/payment_requests\n\n
(the POST request had the first two characters counted as part of previous request)It would also be nice for cowboy or phoenix to surface that
ST
is an unknown method. https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#405