mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1214305 - Part 2: Refactor the logic for obtaining the secure upgraded URI into HttpBaseChannel; r=mcmanus
This commit is contained in:
parent
627f8c2965
commit
b3c25cae2e
@ -3125,6 +3125,35 @@ HttpBaseChannel::SetCorsPreflightParameters(const nsTArray<nsCString>& aUnsafeHe
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
HttpBaseChannel::GetSecureUpgradedURI(nsIURI* aURI, nsIURI** aUpgradedURI)
|
||||
{
|
||||
nsCOMPtr<nsIURI> upgradedURI;
|
||||
|
||||
nsresult rv = aURI->Clone(getter_AddRefs(upgradedURI));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
upgradedURI->SetScheme(NS_LITERAL_CSTRING("https"));
|
||||
|
||||
int32_t oldPort = -1;
|
||||
rv = aURI->GetPort(&oldPort);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Keep any nonstandard ports so only the scheme is changed.
|
||||
// For example:
|
||||
// http://foo.com:80 -> https://foo.com:443
|
||||
// http://foo.com:81 -> https://foo.com:81
|
||||
|
||||
if (oldPort == 80 || oldPort == -1)
|
||||
upgradedURI->SetPort(-1);
|
||||
else
|
||||
upgradedURI->SetPort(oldPort);
|
||||
|
||||
upgradedURI.forget(aUpgradedURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -300,6 +300,10 @@ public: /* Necko internal use only... */
|
||||
// the new mUploadStream.
|
||||
void EnsureUploadStreamIsCloneableComplete(nsresult aStatus);
|
||||
|
||||
// Returns an https URI for channels that need to go through secure
|
||||
// upgrades.
|
||||
static nsresult GetSecureUpgradedURI(nsIURI* aURI, nsIURI** aUpgradedURI);
|
||||
|
||||
protected:
|
||||
nsCOMArray<nsISecurityConsoleMessage> mSecurityConsoleMessages;
|
||||
|
||||
|
@ -1868,30 +1868,12 @@ nsHttpChannel::HandleAsyncRedirectChannelToHttps()
|
||||
nsresult
|
||||
nsHttpChannel::StartRedirectChannelToHttps()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
LOG(("nsHttpChannel::HandleAsyncRedirectChannelToHttps() [STS]\n"));
|
||||
|
||||
nsCOMPtr<nsIURI> upgradedURI;
|
||||
|
||||
rv = mURI->Clone(getter_AddRefs(upgradedURI));
|
||||
nsresult rv = GetSecureUpgradedURI(mURI, getter_AddRefs(upgradedURI));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
upgradedURI->SetScheme(NS_LITERAL_CSTRING("https"));
|
||||
|
||||
int32_t oldPort = -1;
|
||||
rv = mURI->GetPort(&oldPort);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Keep any nonstandard ports so only the scheme is changed.
|
||||
// For example:
|
||||
// http://foo.com:80 -> https://foo.com:443
|
||||
// http://foo.com:81 -> https://foo.com:81
|
||||
|
||||
if (oldPort == 80 || oldPort == -1)
|
||||
upgradedURI->SetPort(-1);
|
||||
else
|
||||
upgradedURI->SetPort(oldPort);
|
||||
|
||||
return StartRedirectChannelToURI(upgradedURI,
|
||||
nsIChannelEventSink::REDIRECT_PERMANENT |
|
||||
nsIChannelEventSink::REDIRECT_STS_UPGRADE);
|
||||
|
Loading…
Reference in New Issue
Block a user