Commit 97795250 authored by momohatt's avatar momohatt Committed by Commit Bot

[ServiceWorkerNewScriptLoader] Set headers only for main script requests

Spec requires that in the update of service workers, we should set the
header only for the network request of the main script, and we shouldn't
set headers for that of imported scripts.
(https://w3c.github.io/ServiceWorker/#update-algorithm)

Current ServiceWorkerNewScriptLoader sets the header for both kinds of
the scripts, so this patch fixes it to conform to the spec.

Change-Id: I159019e492ea212e58e6b0fcdf3f9a1e57928bdb
Reviewed-on: https://chromium-review.googlesource.com/1249422
Commit-Queue: Makoto Shimazu <shimazu@chromium.org>
Reviewed-by: default avatarMakoto Shimazu <shimazu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595373}
parent 7041363f
...@@ -90,6 +90,8 @@ ServiceWorkerNewScriptLoader::ServiceWorkerNewScriptLoader( ...@@ -90,6 +90,8 @@ ServiceWorkerNewScriptLoader::ServiceWorkerNewScriptLoader(
// may be used by ServiceWorkerNavigationLoader for navigations handled // may be used by ServiceWorkerNavigationLoader for navigations handled
// by this service worker. // by this service worker.
options |= network::mojom::kURLLoadOptionSendSSLInfoWithResponse; options |= network::mojom::kURLLoadOptionSendSSLInfoWithResponse;
resource_request.headers.SetHeader("Service-Worker", "script");
} }
// Bypass the browser cache if needed, e.g., updateViaCache demands it or 24 // Bypass the browser cache if needed, e.g., updateViaCache demands it or 24
...@@ -103,8 +105,6 @@ ServiceWorkerNewScriptLoader::ServiceWorkerNewScriptLoader( ...@@ -103,8 +105,6 @@ ServiceWorkerNewScriptLoader::ServiceWorkerNewScriptLoader(
resource_request.load_flags |= net::LOAD_BYPASS_CACHE; resource_request.load_flags |= net::LOAD_BYPASS_CACHE;
} }
resource_request.headers.SetHeader("Service-Worker", "script");
// Create response readers only when we have to do the byte-for-byte check. // Create response readers only when we have to do the byte-for-byte check.
std::unique_ptr<ServiceWorkerResponseReader> compare_reader; std::unique_ptr<ServiceWorkerResponseReader> compare_reader;
std::unique_ptr<ServiceWorkerResponseReader> copy_reader; std::unique_ptr<ServiceWorkerResponseReader> copy_reader;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment