Bug 1337543 P6 Persist response headers for offlined service worker scripts. r=baku

This commit is contained in:
Ben Kelly 2017-02-13 12:15:59 -05:00
parent 7529d95c7c
commit 414b756468
2 changed files with 19 additions and 4 deletions

View File

@ -671,6 +671,7 @@ private:
RefPtr<mozilla::dom::InternalResponse> ir =
new mozilla::dom::InternalResponse(200, NS_LITERAL_CSTRING("OK"));
ir->SetBody(loadInfo.mCacheReadStream, InternalResponse::UNKNOWN_BODY_SIZE);
// Drop our reference to the stream now that we've passed it along, so it
// doesn't hang around once the cache is done with it and keep data alive.
loadInfo.mCacheReadStream = nullptr;
@ -699,6 +700,7 @@ private:
}
ir->SetPrincipalInfo(Move(principalInfo));
ir->Headers()->FillResponseHeaders(loadInfo.mChannel);
RefPtr<mozilla::dom::Response> response =
new mozilla::dom::Response(mCacheCreator->Global(), ir);

View File

@ -240,6 +240,7 @@ public:
CompareCallback* aCallback)
: mRegistration(aRegistration)
, mCallback(aCallback)
, mInternalHeaders(new InternalHeaders())
, mState(WaitingForOpen)
, mNetworkFinished(false)
, mCacheFinished(false)
@ -434,10 +435,19 @@ public:
return mCacheStorage;
}
void
InitChannelInfo(nsIChannel* aChannel)
nsresult
OnStartRequest(nsIChannel* aChannel)
{
nsresult rv = SetPrincipalInfo(aChannel);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
mChannelInfo.InitFromChannel(aChannel);
mInternalHeaders->FillResponseHeaders(aChannel);
return NS_OK;
}
nsresult
@ -562,6 +572,9 @@ private:
ir->SetPrincipalInfo(Move(mPrincipalInfo));
}
IgnoredErrorResult ignored;
ir->Headers()->Fill(*mInternalHeaders, ignored);
RefPtr<Response> response = new Response(aCache->GetGlobalObject(), ir);
RequestOrUSVString request;
@ -594,6 +607,7 @@ private:
nsString mNewCacheName;
ChannelInfo mChannelInfo;
RefPtr<InternalHeaders> mInternalHeaders;
UniquePtr<mozilla::ipc::PrincipalInfo> mPrincipalInfo;
@ -693,8 +707,7 @@ CompareNetwork::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
MOZ_ASSERT(channel == mChannel);
#endif
mManager->InitChannelInfo(mChannel);
nsresult rv = mManager->SetPrincipalInfo(mChannel);
nsresult rv = mManager->OnStartRequest(mChannel);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}