Re: XHR setting headers

* Julian Reschke wrote:
>Peter Michaux wrote:
>> 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.
>
>The whole "append" semantics is problematic as long as the user can't 
>find out what the current value is.
>
>IMHO we need either removeRequestHeader(), getRequestHeader(), or both.

I once suggested making setRequestHeader with null remove the stored
value, I am not sure why this has no effect instead. I do note that it
is unlikely that the set of headers the implementation will ultimately
pass on to the next hop will ever be fully deterministic based only on
published specifications. Similarily, I don't think mixing control over
your own headers, and those added or modified by the implementation in
the same API is a good idea: it cannot know whether removeRH is meant
to simply clear a previous setRequestHeader value, or meant to somehow
surpress an implementation default; the implementation also may not be
able to accurately predict the value of certain headers at the point
where the script wants to know them (or what it does report becomes in-
valid because other headers are set by the script). One case here is if
the client learns about certain features of the server only the moment
before the request is dispatched (like whether it supports HTTP/1.1 or
pipelined requests or has some particular bug that needs to be worked
around). So I would suggest a separate API is in order here, if one is
needed at all.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 

Received on Wednesday, 14 May 2008 13:49:19 UTC