You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, this is incorrect; it should test options.data && options.method!="GET" in both cases, since in the HTML protocol if the Content-Type is specified and Content-Length is not then the server should read until the end of the request, and omitting Content-Length is highly undesirable and permitted primarily for backward compatibility with HTTP 1.0. Some servers, and the one I am using is one of them, will reject an API request if the content length is not given but the content type is since it's defeats HTTP 1.1 keep-alive.
Putting it more succinctly, if there is no content, don't set the content-type header.
Where I am seeing this fail is on RESTful DELETE requests, which quite naturally have no request content. I've worked around it by detecting an omitted data object and setting it to "" in my wrapper, which then causes Content-Length: 0, but the right solution is to fix Mithril (IMO).
(As an aside, the HTTP spec technically permits content with a GET request, though with severe drawbacks relating to proxies and caching, so while it's unusual the data should not, technically, be omitted for GET. However, the current implementation may be convenient, so having an option to send content with a GET may be desirable, though it's not what I am asking for here.)
The text was updated successfully, but these errors were encountered:
Currently, in the bowels of
m.render
we see:However, this is incorrect; it should test
options.data && options.method!="GET"
in both cases, since in the HTML protocol if the Content-Type is specified and Content-Length is not then the server should read until the end of the request, and omitting Content-Length is highly undesirable and permitted primarily for backward compatibility with HTTP 1.0. Some servers, and the one I am using is one of them, will reject an API request if the content length is not given but the content type is since it's defeats HTTP 1.1 keep-alive.Putting it more succinctly, if there is no content, don't set the content-type header.
Where I am seeing this fail is on RESTful DELETE requests, which quite naturally have no request content. I've worked around it by detecting an omitted data object and setting it to "" in my wrapper, which then causes
Content-Length: 0
, but the right solution is to fix Mithril (IMO).(As an aside, the HTTP spec technically permits content with a GET request, though with severe drawbacks relating to proxies and caching, so while it's unusual the data should not, technically, be omitted for GET. However, the current implementation may be convenient, so having an option to send content with a GET may be desirable, though it's not what I am asking for here.)
The text was updated successfully, but these errors were encountered: