|
Delay generation of User-Agent header to URLRequestHttpJob and accept custom User-Agent from XHR/Fetch
To conform to the Fetch Standard, User-Agent header generation should be
done after consulting a ServiceWorker (see that the step is in
HTTP-network-or-cache fetch which is performed after ServiceWorker).
Chromium has been violating this requirement. Renderer generates a
User-Agent header and it's visible to the ServiceWorker which controls
the page.
This spec violation also prevented allowing for custom User-Agent header
which was enabled by https://github.com/whatwg/fetch/issues/37 because
a User-Agent header appended by the controlled page is considered to be
a author provided header by fetch() in a ServiceWorker and may cause
unnecessary wrong preflight.
This change fixes both of these issues while preserving the inspector's
functionality to override User-Agent, by introducing a new path in the
resource loader to pass the User-Agent string generated and added by
FrameFetchContext to net::URLRequest instead of embedding it in the
list of headers immediately in FrameFetchContext.
The logic in this CL doesn't preserve the default User-Agent value
overridden by the Inspector for the controlled page if it's proxied by
a ServiceWorker. But this is not working even before this CL. "request"
guard and "request-no-cors" guard rejects User-Agent value added by
the controlled page on fetch() call in a ServiceWorker. See
http://crbug.com/638552.
Note about layouttest changes:
User-Agent and Authorization are removed from
http/tests/xmlhttprequest/set-dangerous-headers.html as Authorization
is tested by authorization-header.html and User-Agent will be tested by
setrequestheader-useragent.html introduced by this CL.
print-headers.cgi should be merged with echo-headers.php. This is not
done in this CL not to increase the patch size any more. See
http://crbug.com/638553.
BUG= 595993, 571722, 638552, 638553
Total comments: 9
Total comments: 13
|
Unified diffs |
Side-by-side diffs |
Delta from patch set |
Stats (+343 lines, -86 lines) |
Patch |
 |
M |
android_webview/javatests/src/org/chromium/android_webview/test/LoadUrlTest.java
|
View
|
1
2
3
4
5
6
7
8
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
content/browser/loader/resource_dispatcher_host_impl.cc
|
View
|
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
 |
M |
content/child/request_info.h
|
View
|
|
1 chunk |
+4 lines, -0 lines |
0 comments
|
Download
|
 |
M |
content/child/resource_dispatcher.cc
|
View
|
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
 |
M |
content/child/web_url_loader_impl.cc
|
View
|
1
2
3
4
5
6
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
 |
M |
content/common/resource_messages.h
|
View
|
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
 |
M |
content/common/resource_request.h
|
View
|
|
1 chunk |
+4 lines, -0 lines |
0 comments
|
Download
|
 |
M |
net/url_request/url_request.h
|
View
|
1
2
3
4
5
6
|
2 chunks |
+6 lines, -0 lines |
0 comments
|
Download
|
 |
M |
net/url_request/url_request.cc
|
View
|
1
2
3
4
5
6
|
2 chunks |
+10 lines, -0 lines |
0 comments
|
Download
|
 |
M |
net/url_request/url_request_http_job.cc
|
View
|
|
1 chunk |
+5 lines, -0 lines |
0 comments
|
Download
|
 |
M |
ppapi/tests/test_url_loader.cc
|
View
|
1
2
3
|
1 chunk |
+0 lines, -1 line |
0 comments
|
Download
|
 |
M |
third_party/WebKit/LayoutTests/fast/xmlhttprequest/set-dangerous-headers-local.html
|
View
|
1
2
3
4
|
1 chunk |
+0 lines, -1 line |
0 comments
|
Download
|
 |
M |
third_party/WebKit/LayoutTests/fast/xmlhttprequest/set-dangerous-headers-local-expected.txt
|
View
|
1
2
3
4
|
1 chunk |
+7 lines, -8 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/LayoutTests/http/tests/fetch/resources/fetch-test-helpers.js
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
third_party/WebKit/LayoutTests/http/tests/fetch/resources/thorough-util.js
|
View
|
|
3 chunks |
+5 lines, -3 lines |
0 comments
|
Download
|
 |
A |
third_party/WebKit/LayoutTests/http/tests/fetch/resources/useragent-header.js
|
View
|
1
2
3
4
5
6
|
1 chunk |
+16 lines, -0 lines |
0 comments
|
Download
|
 |
A |
third_party/WebKit/LayoutTests/http/tests/fetch/resources/useragent-header-iframe.html
|
View
|
1
2
3
4
5
6
|
1 chunk |
+22 lines, -0 lines |
4 comments
|
Download
|
 |
M |
third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/request.js
|
View
|
1
|
1 chunk |
+1 line, -2 lines |
0 comments
|
Download
|
 |
A |
third_party/WebKit/LayoutTests/http/tests/fetch/serviceworker-proxied/useragent-header-via-empty-worker.html
|
View
|
1
2
3
4
5
6
|
1 chunk |
+39 lines, -0 lines |
5 comments
|
Download
|
 |
A |
third_party/WebKit/LayoutTests/http/tests/fetch/serviceworker-proxied/useragent-header-via-forwarding-worker.html
|
View
|
1
2
3
4
5
6
|
1 chunk |
+63 lines, -0 lines |
2 comments
|
Download
|
 |
A |
third_party/WebKit/LayoutTests/http/tests/fetch/window/useragent-header.html
|
View
|
1
2
3
4
5
6
|
1 chunk |
+25 lines, -0 lines |
2 comments
|
Download
|
 |
M |
third_party/WebKit/LayoutTests/http/tests/inspector/extensions-headers.html
|
View
|
1
2
3
4
5
|
1 chunk |
+27 lines, -2 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/LayoutTests/http/tests/inspector/extensions-headers-expected.txt
|
View
|
1
|
1 chunk |
+2 lines, -2 lines |
0 comments
|
Download
|
 |
D |
third_party/WebKit/LayoutTests/http/tests/inspector/resources/echo-headers.php
|
View
|
1
2
3
4
|
1 chunk |
+0 lines, -9 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/LayoutTests/http/tests/inspector/service-workers/resources/user-agent-override-worker.js
|
View
|
1
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
A |
third_party/WebKit/LayoutTests/http/tests/resources/echo-headers.php
|
View
|
1
2
3
4
|
1 chunk |
+5 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/LayoutTests/http/tests/serviceworker/fetch-event.html
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
third_party/WebKit/LayoutTests/http/tests/serviceworker/request-end-to-end.html
|
View
|
1
2
3
4
|
1 chunk |
+0 lines, -2 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-request-xhr-iframe.html
|
View
|
1
2
3
4
|
4 chunks |
+4 lines, -4 lines |
0 comments
|
Download
|
 |
A |
third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/forwarding-worker.js
|
View
|
1
2
3
4
5
6
|
1 chunk |
+15 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/set-dangerous-headers.html
|
View
|
1
|
4 chunks |
+2 lines, -8 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/set-dangerous-headers-expected.txt
|
View
|
1
2
3
4
|
1 chunk |
+22 lines, -23 lines |
0 comments
|
Download
|
 |
A |
third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/setrequestheader-useragent.html
|
View
|
1
2
3
4
|
1 chunk |
+30 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/core/fetch/FetchUtils.cpp
|
View
|
|
1 chunk |
+0 lines, -1 line |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
|
View
|
1
2
3
4
5
6
|
3 chunks |
+3 lines, -4 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/core/loader/FrameLoader.h
|
View
|
|
1 chunk |
+0 lines, -2 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/core/loader/FrameLoader.cpp
|
View
|
|
1 chunk |
+0 lines, -7 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/platform/exported/WebURLRequest.cpp
|
View
|
|
1 chunk |
+5 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/platform/network/ResourceRequest.h
|
View
|
|
3 chunks |
+5 lines, -2 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/platform/network/ResourceRequest.cpp
|
View
|
|
2 chunks |
+2 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/platform/network/ResourceRequestTest.cpp
|
View
|
1
2
3
4
5
6
7
|
3 chunks |
+3 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/AssociatedURLLoaderTest.cpp
|
View
|
1
2
3
|
1 chunk |
+0 lines, -1 line |
0 comments
|
Download
|
 |
M |
third_party/WebKit/public/platform/WebURLRequest.h
|
View
|
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
Total messages: 25 (13 generated)
|