W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2012

[XHR] XMLHttpRequest.send("")

From: Jonas Sicking <jonas@sicking.cc>
Date: Tue, 10 Apr 2012 15:08:47 -0700
Message-ID: <CA+c2ei_0mHzpZp45M5XgW2ZFFsxVB3iX0NKyyOjJQXDuhaBdiA@mail.gmail.com>
To: Webapps WG <public-webapps@w3.org>
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 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:51 GMT