mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 07:18:39 +09:00
ported from mozilla: Bug 1264792 - Update request'referrer policy when redirect.r=bkelly,dragana. (763507de3e)
This commit is contained in:
parent
ed16ab739e
commit
97fb5d7f9b
16 changed files with 244 additions and 91 deletions
|
|
@ -1681,8 +1681,13 @@ NS_IMETHODIMP
|
|||
HttpChannelChild::OnRedirectVerifyCallback(nsresult result)
|
||||
{
|
||||
LOG(("HttpChannelChild::OnRedirectVerifyCallback [this=%p]\n", this));
|
||||
OptionalURIParams redirectURI;
|
||||
nsresult rv;
|
||||
OptionalURIParams redirectURI;
|
||||
|
||||
uint32_t referrerPolicy = REFERRER_POLICY_NO_REFERRER_WHEN_DOWNGRADE;
|
||||
OptionalURIParams referrerURI;
|
||||
SerializeURI(nullptr, referrerURI);
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> newHttpChannel =
|
||||
do_QueryInterface(mRedirectChannelChild);
|
||||
|
||||
|
|
@ -1700,6 +1705,12 @@ HttpChannelChild::OnRedirectVerifyCallback(nsresult result)
|
|||
if (newHttpChannel) {
|
||||
// Must not be called until after redirect observers called.
|
||||
newHttpChannel->SetOriginalURI(mOriginalURI);
|
||||
|
||||
newHttpChannel->GetReferrerPolicy(&referrerPolicy);
|
||||
nsCOMPtr<nsIURI> newChannelReferrerURI;
|
||||
newHttpChannel->GetReferrer(getter_AddRefs(newChannelReferrerURI));
|
||||
|
||||
SerializeURI(newChannelReferrerURI, referrerURI);
|
||||
}
|
||||
|
||||
if (mRedirectingForSubsequentSynthesizedResponse) {
|
||||
|
|
@ -1770,8 +1781,9 @@ HttpChannelChild::OnRedirectVerifyCallback(nsresult result)
|
|||
}
|
||||
|
||||
if (mIPCOpen)
|
||||
SendRedirect2Verify(result, *headerTuples, loadFlags, redirectURI,
|
||||
corsPreflightArgs, chooseAppcache);
|
||||
SendRedirect2Verify(result, *headerTuples, loadFlags, referrerPolicy,
|
||||
referrerURI, redirectURI, corsPreflightArgs,
|
||||
chooseAppcache);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -2147,6 +2159,25 @@ HttpChannelChild::ContinueAsyncOpen()
|
|||
// HttpChannelChild::nsIHttpChannel
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpChannelChild::SetReferrerWithPolicy(nsIURI *referrer,
|
||||
uint32_t referrerPolicy)
|
||||
{
|
||||
ENSURE_CALLED_BEFORE_CONNECT();
|
||||
|
||||
// remove old referrer if any, loop backwards
|
||||
for (int i = mClientSetRequestHeaders.Length() - 1; i >= 0; --i) {
|
||||
if (NS_LITERAL_CSTRING("Referer").Equals(mClientSetRequestHeaders[i].mHeader)) {
|
||||
mClientSetRequestHeaders.RemoveElementAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult rv = HttpBaseChannel::SetReferrerWithPolicy(referrer, referrerPolicy);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
HttpChannelChild::SetRequestHeader(const nsACString& aHeader,
|
||||
const nsACString& aValue,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue