Bug 1319846 P1 Deserialize headers before restoring guard value when reading from Cache API. r=asuth
authorBen Kelly <ben@wanderview.com>
Mon, 28 Nov 2016 14:18:27 -0800
changeset 324462 ac1e6c7e2a43f970fc638802ef39fb65b138a452
parent 324461 69cad8c3ffd295a48ff8e66d5e17a275c0250c8d
child 324463 2b7386abfe14b66dd37391dd3752975728e40231
push id84420
push userbkelly@mozilla.com
push dateMon, 28 Nov 2016 22:19:06 +0000
treeherdermozilla-inbound@7e1519cd5349 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1319846
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1319846 P1 Deserialize headers before restoring guard value when reading from Cache API. r=asuth
dom/cache/TypeUtils.cpp
--- a/dom/cache/TypeUtils.cpp
+++ b/dom/cache/TypeUtils.cpp
@@ -258,19 +258,22 @@ TypeUtils::ToResponse(const CacheRespons
 
   RefPtr<InternalResponse> ir = new InternalResponse(aIn.status(),
                                                        aIn.statusText());
   ir->SetURLList(aIn.urlList());
 
   RefPtr<InternalHeaders> internalHeaders =
     ToInternalHeaders(aIn.headers(), aIn.headersGuard());
   ErrorResult result;
-  ir->Headers()->SetGuard(aIn.headersGuard(), result);
+
+  // Be careful to fill the headers before setting the guard in order to
+  // correctly re-create the original headers.
+  ir->Headers()->Fill(*internalHeaders, result);
   MOZ_ASSERT(!result.Failed());
-  ir->Headers()->Fill(*internalHeaders, result);
+  ir->Headers()->SetGuard(aIn.headersGuard(), result);
   MOZ_ASSERT(!result.Failed());
 
   ir->InitChannelInfo(aIn.channelInfo());
   if (aIn.principalInfo().type() == mozilla::ipc::OptionalPrincipalInfo::TPrincipalInfo) {
     UniquePtr<mozilla::ipc::PrincipalInfo> info(new mozilla::ipc::PrincipalInfo(aIn.principalInfo().get_PrincipalInfo()));
     ir->SetPrincipalInfo(Move(info));
   }