mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1745650 - If a download upgrades to https via httpsFirst-/httpsOnly - mode it fails. r=ckerschb,necko-reviewers,dragana
Differential Revision: https://phabricator.services.mozilla.com/D133882
This commit is contained in:
parent
f1670e6b04
commit
68ea9d8493
@ -680,6 +680,10 @@ static void LogHTTPSOnlyInfo(nsILoadInfo* aLoadInfo) {
|
||||
MOZ_LOG(sCSMLog, LogLevel::Verbose,
|
||||
(" - HTTPS_ONLY_TOP_LEVEL_LOAD_IN_PROGRESS"));
|
||||
}
|
||||
if (httpsOnlyStatus & nsILoadInfo::HTTPS_ONLY_DOWNLOAD_IN_PROGRESS) {
|
||||
MOZ_LOG(sCSMLog, LogLevel::Verbose,
|
||||
(" - HTTPS_ONLY_DOWNLOAD_IN_PROGRESS"));
|
||||
}
|
||||
if (httpsOnlyStatus & nsILoadInfo::HTTPS_ONLY_DO_NOT_LOG_TO_CONSOLE) {
|
||||
MOZ_LOG(sCSMLog, LogLevel::Verbose,
|
||||
(" - HTTPS_ONLY_DO_NOT_LOG_TO_CONSOLE"));
|
||||
|
@ -986,8 +986,11 @@ TestHTTPAnswerRunnable::Notify(nsITimer* aTimer) {
|
||||
nsCOMPtr<nsIChannel> origChannel = mDocumentLoadListener->GetChannel();
|
||||
nsCOMPtr<nsILoadInfo> origLoadInfo = origChannel->LoadInfo();
|
||||
uint32_t origHttpsOnlyStatus = origLoadInfo->GetHttpsOnlyStatus();
|
||||
if ((origHttpsOnlyStatus &
|
||||
nsILoadInfo::HTTPS_ONLY_TOP_LEVEL_LOAD_IN_PROGRESS)) {
|
||||
uint32_t topLevelLoadInProgress =
|
||||
origHttpsOnlyStatus & nsILoadInfo::HTTPS_ONLY_TOP_LEVEL_LOAD_IN_PROGRESS;
|
||||
uint32_t downloadInProgress =
|
||||
origHttpsOnlyStatus & nsILoadInfo::HTTPS_ONLY_DOWNLOAD_IN_PROGRESS;
|
||||
if (topLevelLoadInProgress || downloadInProgress) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -464,17 +464,25 @@ interface nsILoadInfo : nsISupports
|
||||
*/
|
||||
const unsigned long HTTPS_ONLY_TOP_LEVEL_LOAD_IN_PROGRESS = (1 << 4);
|
||||
|
||||
/**
|
||||
* This flag indicates that the request should not be logged to the
|
||||
* console.
|
||||
/**
|
||||
* This flag can only ever be set on downloads. It indicates
|
||||
* that the download https connection succeeded. This flag is mostly
|
||||
* used to counter time-outs which allows to cancel the channel
|
||||
* if the https load has not started.
|
||||
*/
|
||||
const unsigned long HTTPS_ONLY_DO_NOT_LOG_TO_CONSOLE = (1 << 5);
|
||||
const unsigned long HTTPS_ONLY_DOWNLOAD_IN_PROGRESS = (1 << 5);
|
||||
|
||||
/**
|
||||
* This flag indicates that the request should not be logged to the
|
||||
* console.
|
||||
*/
|
||||
const unsigned long HTTPS_ONLY_UPGRADED_HTTPS_FIRST = (1 << 6);
|
||||
const unsigned long HTTPS_ONLY_DO_NOT_LOG_TO_CONSOLE = (1 << 6);
|
||||
|
||||
/**
|
||||
* This flag indicates that the request should not be logged to the
|
||||
* console.
|
||||
*/
|
||||
const unsigned long HTTPS_ONLY_UPGRADED_HTTPS_FIRST = (1 << 7);
|
||||
|
||||
/**
|
||||
* Upgrade state of HTTPS-Only Mode. The flag HTTPS_ONLY_EXEMPT can get
|
||||
|
@ -96,6 +96,8 @@
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "ExternalHelperAppChild.h"
|
||||
|
||||
#include "mozilla/dom/nsHTTPSOnlyUtils.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
# include "nsWindowsHelpers.h"
|
||||
#endif
|
||||
@ -1741,6 +1743,17 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest* request) {
|
||||
// Now get the URI
|
||||
if (aChannel) {
|
||||
aChannel->GetURI(getter_AddRefs(mSourceUrl));
|
||||
// HTTPS-Only/HTTPS-FirstMode tries to upgrade connections to https. Once
|
||||
// the download is in progress we set that flag so that timeout counter
|
||||
// measures do not kick in.
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
|
||||
bool isPrivateWin = loadInfo->GetOriginAttributes().mPrivateBrowsingId > 0;
|
||||
if (nsHTTPSOnlyUtils::IsHttpsOnlyModeEnabled(isPrivateWin) ||
|
||||
nsHTTPSOnlyUtils::IsHttpsFirstModeEnabled(isPrivateWin)) {
|
||||
uint32_t httpsOnlyStatus = loadInfo->GetHttpsOnlyStatus();
|
||||
httpsOnlyStatus |= nsILoadInfo::HTTPS_ONLY_DOWNLOAD_IN_PROGRESS;
|
||||
loadInfo->SetHttpsOnlyStatus(httpsOnlyStatus);
|
||||
}
|
||||
}
|
||||
|
||||
if (!mForceSave && StaticPrefs::browser_download_enable_spam_prevention() &&
|
||||
|
Loading…
Reference in New Issue
Block a user