Bug 1433958 - Change code that uses nsIURI.setHostAndPort() to use nsIURIMutator r=mayhemer

* Removes setHostAndPort from nsIURIMutator as it only has one use
* Instead, the consumer sets the port to -1 before calling setHostPort()

MozReview-Commit-ID: Jx9UMW440hq
This commit is contained in:
Valentin Gosu
2018-02-26 20:43:45 +01:00
parent 370e4e7af3
commit 40fc96e930
2 changed files with 8 additions and 27 deletions

View File

@@ -29,6 +29,7 @@
#include "nsDOMString.h"
#include "nsIStreamListener.h"
#include "nsIURI.h"
#include "nsIURIMutator.h"
#include "nsIIOService.h"
#include "nsNetUtil.h"
#include "nsIPrivateBrowsingChannel.h"
@@ -926,24 +927,17 @@ nsHTMLDocument::CreateInheritingURIForHost(const nsACString& aHostString)
return nullptr;
}
nsCOMPtr<nsIURI> newURI;
nsresult rv = uri->Clone(getter_AddRefs(newURI));
nsresult rv;
rv = NS_MutateURI(uri)
.SetUserPass(EmptyCString())
.SetPort(-1) // we want to reset the port number if needed.
.SetHostPort(aHostString)
.Finalize(uri);
if (NS_FAILED(rv)) {
return nullptr;
}
rv = newURI->SetUserPass(EmptyCString());
if (NS_FAILED(rv)) {
return nullptr;
}
// We use SetHostAndPort because we want to reset the port number if needed.
rv = newURI->SetHostAndPort(aHostString);
if (NS_FAILED(rv)) {
return nullptr;
}
return newURI.forget();
return uri.forget();
}
already_AddRefed<nsIURI>