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 349395 e8ad14b973ac729dbc57869f1b690f6b78713242
parent 349394 38176b5357f07869d8d7bf718cfd34fc2696cfd5
child 349396 d85bdb39cf3fab0f4d7a5a50295e08b8063d14e3
push id10377
push userryanvm@gmail.com
push dateWed, 30 Nov 2016 03:59:25 +0000
treeherdermozilla-aurora@96503957841c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth, gchang
bugs1319846
milestone52.0a2
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
@@ -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));
   }