W3C home > Mailing lists > Public > public-webapi@w3.org > April 2008

XHR setting headers

From: Peter Michaux <petermichaux@gmail.com>
Date: Wed, 16 Apr 2008 16:49:44 -0700
Message-ID: <3cbaf1c80804161649v796d4df7u7880c6f64a86ac9d@mail.gmail.com>
To: public-webapi@w3.org

The XMLHttpRequest spec says "The setRequestHeader() method appends a
value if the HTTP header given as argument is already part of the list
of request headers."
This is fine but what is a problem is whether or not a new
XHMHttpRequest object has any default headers. I was trying to use the
Accept header a few days ago and I wanted to have only

Accept: application/json

but Opera has a default header

Accept: text/html, text/xhtml, etc

so my application/json was appended to the front of that list which
makes my Accept header useless as part of the client-server
communication. The server thinks that the client knows what to do with
text/html. My JavaScript certainly does NOT know what to do with
text/html. My JavaScript only knows how to handle application/json.

I think all XMLHttpRequest headers should be specified as blank when
the object is created. Then the JavaScript can add any headers it
needs to add. If, when the call to send() occurs, some essential
header(s) is missing the XHMLHttpRequest object should add these
automatically but only according to specified behavior.

Peter
Received on Thursday, 17 April 2008 03:11:00 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 17 April 2008 03:11:05 GMT