There's no need to allocate a completely new nsCString when all we want
to do is parse a character string into an integer. We can allocate a
dependent string instead, which will avoid some memory churn.
Otherwise it will just load back the same (problematic) addresses from the
cache again the second time. This introduces a new resolver bit
(REFRESH_CACHE) that also invalidates the existing cache entry while doing the
new resolve.
MozReview-Commit-ID: 5Bc2KiAGYYA
--HG--
extra : rebase_source : ae368c88a5db27f0980b9928439d27588bc84815
What we're really doing in CacheEntry::CheckRequest is checking:
a) Whether the method is contained in our allowed methods; and
b) Whether all of the headers are contained in our allowed headers.
nsTArray lets us check directly for containing elements, so let's use
that facility rather than rolling our own.
nsCaseInsensitiveCStringComparator ought to be cheap to construct, but
the object actually has a vtable to install and whatnot. So it's
beneficial to pull the construction of it outside of the headers loop.
The entries in mMethods and mHeaders aren't sorted in any special way,
so we can remove expired entries using UnorderedRemoveElementAt, which
is faster than RemoveElementAt.
DNSRequestChild's constructor takes `const nsCString&` parameters. If
you have a `const nsACString&` argument to pass in to the constructor,
you're forced to construct a temporary nsCString object to satisfy the
prototype. But the temporary string will just get copied inside the
constructor and you'll have to destroy the temporary string object you
created.
Let's skip all this, and just have DNSRequestChild take `const
nsACString&` arguments instead, and avoid the temporary object.
Early AAAA responses might cause issues on hosts without working native
IPv6 connectivity, of course especially notable in TRR-only mode.
MozReview-Commit-ID: 6ZqE6AKnucH
--HG--
extra : rebase_source : ff42cb8daf941a3fa1f7e783c76d823e879024c3
WebPlatformTests expect that when calling
url.host = "host:" // port missing
url.host = "host:65536" // port too big
url.host = "host:bla" // invalid port
that the hostname will be set, but the port will be left unchanged.
Since DOM APIs are the only consumers for SetHostPort it means we can change this behaviour to match the WPT expectations.
As such, SetHostPort will return NS_OK if setting the host succeded, and will ignore if setting the port failed.
MozReview-Commit-ID: LoMw8hCWlCv
--HG--
extra : rebase_source : db28b73d98060c2f66f899afe1a4ae26f4db85db
We normally fail in nsStandardURL::SetPassword if the username is empty.
But if the password we are trying to set is also empty, we should't really fail.
MozReview-Commit-ID: FIDqkPrb1gp
--HG--
extra : rebase_source : 9080c44e91e27acd210f3ace3a234528513928c3
* Code in XMLHttpRequestMainThread is converted to set the username and password individually. This is because when the parameters are empty, it ended up calling SetUserPass(":") which always returns an error.
MozReview-Commit-ID: 3cK5HeyzjFE
--HG--
extra : rebase_source : f34400c11245d88648b0ae9c196637628afa9517
Calling NS_ENSURE_SUCCESS at the begining of the methods shows the error in the console, but what we really care about is where the error code comes from. So it is best to use if (NS_FAILED(mStatus) {} at the begining of the methods, and NS_ENSURE_SUCCESS right after calling the appropriate method on mMutator.
MozReview-Commit-ID: 5vVuHk3N4FU
--HG--
extra : rebase_source : f477f0f87b3303422a595f27d9b39ac25335d701
* 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
--HG--
extra : rebase_source : cb60e76c905db6bb308ddfd8fa548cc13d3afe06