forked from mirrors/gecko-dev
		
	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
							
								
									6ba2d43b7b
								
							
						
					
					
						commit
						11c0f63d58
					
				
					 4 changed files with 35 additions and 7 deletions
				
			
		|  | @ -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; | ||||
|   } | ||||
| 
 | ||||
|  |  | |||
|  | @ -465,16 +465,24 @@ 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 a new issue
	
	 lyavor
						lyavor