You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think we 'inherited' User-Agent from a list of headers Flash disallowed changing in its implementation. There was some speculation that some services might exist that only allowed specific customized browsers to access them, using UA string as a sort of auth token, but I don't think anybody ever found a real-life case of such a system. (Obviously it would be astonishingly poor design).
Personally, I think we can and should drop User-Agent from the list of headers you're not allowed to set.
If we allow setting it to any value and effectively replace anything the user agent would set we should probably make it a parameter of RequestInit as the supplied headers argument combines with existing headers (and never replaces). So e.g.
(It might be worth noting that GitHub itself recommends User-Agent set to your GH user name in API requests - this is of course trivial if you write Python/Node/whatever clients, but not currently possible from an API consumer running in a browser. So there's a big and important use case right here.)
If we allow setting it to any value and effectively replace anything the user agent would set we should probably make it a parameter of RequestInit as the supplied headers argument combines with existing headers (and never replaces). So e.g.
Hmm, I'm not sure I necessarily agree. It seems a straightforward extension to say that headers provided by the RequestInit overwrite default headers. What do you think would be confusing about allowing User-Agent to be set through the normal mechanisms?
This helps us contact application owners when there are problems, like a rogue script making lots of API calls. However, many API resources are only available to authenticated sessions, so the user account is already known. And when accessing the API through a browser, the CORS request includes the Origin header.
The User-Agent header guidance in the API is helpful, but it's not necessarily an example for or against this capability being added to fetch.
If we offer customization, I think it would make sense to also offer omitting it altogether e.g. to reduce the size of the request or debug a server. The location matters since by default it is included and the Headers class is not an instruction set but rather a list of headers included in the request.
.02 - it sure would be nice if UA could be appended to, so you can add "mywidget/1.0" or "(test 3)" for example, rather than blowing the entire thing away.
I'm inclined to define 1 in #37 (comment) but leave the omitUserAgent feature out for now since that is harder to tackle (unless @sicking is wrong and it should not require explicit opt-in to omit it).
If we need omitUserAgent please file a new issue. Ideally reach out to user agents for their security requirements, since they're not entirely clear to me.
Activity
hallvors commentedon Apr 5, 2015
I think we 'inherited' User-Agent from a list of headers Flash disallowed changing in its implementation. There was some speculation that some services might exist that only allowed specific customized browsers to access them, using UA string as a sort of auth token, but I don't think anybody ever found a real-life case of such a system. (Obviously it would be astonishingly poor design).
Personally, I think we can and should drop User-Agent from the list of headers you're not allowed to set.
annevk commentedon Apr 5, 2015
If we allow setting it to any value and effectively replace anything the user agent would set we should probably make it a parameter of
RequestInitas the suppliedheadersargument combines with existing headers (and never replaces). So e.g.hallvors commentedon Apr 5, 2015
(It might be worth noting that GitHub itself recommends User-Agent set to your GH user name in API requests - this is of course trivial if you write Python/Node/whatever clients, but not currently possible from an API consumer running in a browser. So there's a big and important use case right here.)
domenic commentedon Apr 5, 2015
Hmm, I'm not sure I necessarily agree. It seems a straightforward extension to say that headers provided by the RequestInit overwrite default headers. What do you think would be confusing about allowing User-Agent to be set through the normal mechanisms?
dgraham commentedon Apr 5, 2015
https://developer.github.com/v3/#user-agent-required
This helps us contact application owners when there are problems, like a rogue script making lots of API calls. However, many API resources are only available to authenticated sessions, so the user account is already known. And when accessing the API through a browser, the CORS request includes the
Originheader.The
User-Agentheader guidance in the API is helpful, but it's not necessarily an example for or against this capability being added tofetch.dgraham commentedon Apr 5, 2015
If
User-Agentis allowed to be assigned, I think the expected usage would be to pass it in with the rest of the headers for the request.annevk commentedon Apr 5, 2015
I guess that might be okay as well. We could have a step in https://fetch.spec.whatwg.org/#http-network-fetch that appends it if it is not already present in HTTPRequest's header list.
annevk commentedon Apr 6, 2015
So actually, the reason you want it to be an argument rather than part of
headersis so you can force it to be omitted.annevk commentedon Apr 6, 2015
Probable rationale for why it is currently forbidden is in this email by @sicking: https://lists.w3.org/Archives/Public/public-webapi/2008May/0456.html
domenic commentedon Apr 6, 2015
Can you expand on this? I don't quite understand why one location or the other would matter for this, or why you would force it to be omitted.
annevk commentedon Apr 6, 2015
If we offer customization, I think it would make sense to also offer omitting it altogether e.g. to reduce the size of the request or debug a server. The location matters since by default it is included and the
Headersclass is not an instruction set but rather a list of headers included in the request.domenic commentedon Apr 6, 2015
Oh, I see!
Would it be conceivable not to set the header by default at all? Hmm, probably not very good, I'm being too Node-influenced here...
So how would you omit it?
omitUserAgent: true?userAgent: null?annevk commentedon Apr 6, 2015
nullwas my idea, sinceundefinedalready means doing the default, which is to include it and seems highly unlikely to change.domenic commentedon Apr 6, 2015
Why would
userAgent: nullbe good, but'User-Agent': nullnot be good?Related question: when you do
const h = new Headers(), doesh.get("User-Agent")return something? Why or why not?annevk commentedon Apr 6, 2015
"User-Agent": null === "User-Agent": "null".new Headers()creates an empty multimap, it is not populated in any way.19 remaining items
mnot commentedon Apr 9, 2015
.02 - it sure would be nice if UA could be appended to, so you can add "mywidget/1.0" or "(test 3)" for example, rather than blowing the entire thing away.
Syntax here:
http://httpwg.github.io/specs/rfc7231.html#header.user-agent
domenic commentedon Apr 9, 2015
navigator.userAgent + 'my string'
annevk commentedon May 7, 2015
@sicking I don't understand why omitting the header altogether is a cause for concern. It wasn't when we stopped sending
Referer.annevk commentedon Jul 17, 2015
I'm inclined to define 1 in #37 (comment) but leave the
omitUserAgentfeature out for now since that is harder to tackle (unless @sicking is wrong and it should not require explicit opt-in to omit it).annevk commentedon Jul 29, 2015
If we need
omitUserAgentplease file a new issue. Ideally reach out to user agents for their security requirements, since they're not entirely clear to me.wanderview commentedon Jul 29, 2015
gecko bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1188932
benwa commentedon Jan 6, 2016
chromium bug: https://crbug.com/571722
dandv commentedon Jun 17, 2020
Is User-Agent still forbidden after dab09b0 ?
annevk commentedon Jun 18, 2020
It's not as per this change.
XHR: allow the user to set the User-Agent header
[fetch] Test that `User-Agent` is not a forbidden request header
[fetch] Test that `User-Agent` is not a forbidden request header (#39301
[fetch] Test that `User-Agent` is not a forbidden request header (web…
Bug 1825738 [wpt PR 39301] - [fetch] Test that `User-Agent` is not a …