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

Re: [XHR] XMLHttpRequest.send("")

From: Jonas Sicking <jonas@sicking.cc>
Date: Tue, 10 Apr 2012 16:15:05 -0700
Message-ID: <CA+c2ei-y4Sqi7i_pnh_Ss_+q6WD4ynoEghO1duCUFvdkxG5J6g@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: Glenn Maynard <glenn@zewt.org>, Anne van Kesteren <annevk@opera.com>, public-webapps@w3.org
On Tue, Apr 10, 2012 at 4:11 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> On Tue, Apr 10, 2012 at 3:58 PM, Glenn Maynard <glenn@zewt.org> wrote:
>> On Tue, Apr 10, 2012 at 5:50 PM, Jonas Sicking <jonas@sicking.cc> wrote:
>>> Is it more surprising than that
>>>
>>> xhr.send(hasSomethingToSend() ? getTheThingToSend() : "");
>>>
>>> sets the Content-Type header even when no body is submitted?
>>
>> That's exactly what I would expect.  A body that happens to have a zero
>> length is still valid text/plain data.

I'm not sure everyone is sharing that expectation.

>> If you want to omit Content-Type in the above case, then you should write:
>>
>> xhr.send(hasSomethingToSend() ? getTheThingToSend() : null);
>
> Or, of course:
>
> if(hasSomethingToSend())
>  xhr.send(getTheThingToSend());

That isn't terribly useful if you're trying to get a response...

If I'm the only one who prefer the other behavior then we should stick
to what the spec already says. I'll make sure Gecko maintains that
behavior as we implement our new WebIDL bindings.

/ Jonas
Received on Tuesday, 10 April 2012 23:16:04 GMT

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