Bug 1319846 - Part 1: Deserialize headers before restoring guard value when reading from Cache API. r=asuth, a=gchang
authorBen Kelly <ben@wanderview.com>
Mon, 28 Nov 2016 14:18:27 -0800
changeset 356798 4847bb920028abc424b6bb93b08f5cf32d58470d
parent 356797 3020d866784aee0bfb487c2b4bbc7d377078e6d7
child 356799 e261a8b9adaa9f9436818263a30db6f7b25e921b
push id6635
push userryanvm@gmail.com
push dateWed, 30 Nov 2016 04:50:15 +0000
treeherdermozilla-beta@34c73c520f93 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth, gchang
bugs1319846
milestone51.0
Bug 1319846 - Part 1: Deserialize headers before restoring guard value when reading from Cache API. r=asuth, a=gchang
dom/cache/TypeUtils.cpp
--- a/dom/cache/TypeUtils.cpp
+++ b/dom/cache/TypeUtils.cpp
@@ -266,19 +266,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));
   }