On Tue, Apr 10, 2012 at 3:58 PM, Glenn Maynard <gl...@zewt.org> wrote:
> On Tue, Apr 10, 2012 at 5:50 PM, Jonas Sicking <jo...@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.
>
> 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());

~TJ

Reply via email to