GNOME Bugzilla – Bug 634513
XMLHttpRequest with empty POST body has no content-length
Last modified: 2012-08-14 15:58:21 UTC
An AJAX POST request with no body -- i.e. request.send(null) -- will not have a Content-Length header set, resulting in an invalid request that will be rejected by most servers with a 411 status code.
It's not "an invalid request" at the HTTP level. While POST normally has a request body, it doesn't syntactically require one. Anyway, the fix here would be for webkitgtk to explicitly call soup_message_headers_set_content_length(msg->request_headers, 0) when it needs to explicitly indicate an empty body as opposed to no body.
CCing the Sergio.
Second ping to the Sergio.
There is a layout tests in WebKit that checks this IIRC... Yeah it's http/tests/xmlhttprequest/methods.html. We have a specific expected result for that test. What Dan suggests LGTM so I guess we can move this to the webkit bz.
I have just checked our expected results for that test and I found this for POST: POST(""): POST(0 bytes), Content-Type: application/xml POST(null): POST(0 bytes), Content-Type: null POST("123"): POST(3 bytes), Content-Type: application/xml As this test is working fine, this means that our current code is adding a Content-Length=0 for POST messages with null body. Benjamin do you have any example that is not working for you? Oh the bug is from 2010, maybe it got fixed in the meantime, I remember working on issues related to that test...
Yeah, this got fixed as https://bugs.webkit.org/show_bug.cgi?id=82036