Re: [fetch] `user-agent` header control (#37)

Right, so why is `userAgent: null !== userAgent: "null"`? This seems kind of WTFWebPlatform-ish to me.

It looks like from my reading of the spec there's no actual way to tell what `User-Agent` header gets sent then (currently)? E.g. `const r = new Request(...); r.headers.get("User-Agent")` will return `undefined`? That seems worrying.

One last point before I go to sleep: I think what's a bit tricky for me here is that the most straightforward mental model for the programmer is that in the constructor, there's some kind of

```js
this.headers = mergeMultimaps(defaultHeaders, passedHeaders);
```

That is, just naively looking at the shape of the API, and knowing the bit of extra information that there are more headers sent in the request/response than you set, I think most programmers will guess that there's a set of default headers and you can set new headers or override old ones by using the `headers` option. So, the deviations we make from that model need to be done cautiously.

For example in that model I think if `passedHeaders` contained `"User-Agent": undefined`, that would override the default `"User-Agent": "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0"`.

It seems like that is not the model though, as evidenced by the `r.headers.get("User-Agent") === undefined`. Rather, `r.headers` is a straight copy of the passed-in headers, and then the actual fetch uses a hidden set of headers which are compiled based on `r.headers` + other knowledge (possibly from RequestInit, also from the cache, also from the user-agent string, etc.)

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/37#issuecomment-89957188

Received on Monday, 6 April 2015 07:20:43 UTC