[XHR] XMLHttpRequest.send("")

Hi All,

Our understanding of the current spec is that if someone calls the
send function and pass "" as the body to be sent, this is almost
equivalent to not passing a body at all. However, it still changes
which Content-Type header is set. Consider the following code:

xhr = new XMLHttpRequest;
xhr.open("POST", url);
xhr.send("");

The current spec seems to say that this should set the Content-Type
request header to "text/plain" with a utf8 charset.

However it seems a bit strange to me to set this header when
absolutely no request body is sent. I had expected that xhr.send(),
xhr.send(null) and xhr.send("") all would have the same behavior.

The same thing happens if you pass a object which has a toString
function which returns "".

Is this intentional?

This does match what Gecko does, but we are willing to change this if
others agree that it's a better behavior.

/ Jonas

Received on Tuesday, 10 April 2012 22:09:46 UTC