mirror of
https://github.com/roytam1/basilisk55.git
synced 2026-05-26 15:02:46 +00:00
ported from UXP: [network] Stop treating http and https as different for encoding schemes. (3612f45a)
This commit is contained in:
@@ -1568,9 +1568,7 @@ pref("network.http.redirection-limit", 20);
|
||||
// Enable http compression: comment this out in case of problems with 1.1
|
||||
// NOTE: support for "compress" has been disabled per bug 196406.
|
||||
// NOTE: separate values with comma+space (", "): see bug 576033
|
||||
// NOTE: there is currently no reason except evangelism for https to not use brotli for http
|
||||
pref("network.http.accept-encoding", "gzip, deflate, br");
|
||||
pref("network.http.accept-encoding.secure", "gzip, deflate, br");
|
||||
|
||||
pref("network.http.pipelining" , false);
|
||||
pref("network.http.pipelining.ssl" , false); // disable pipelining over SSL
|
||||
|
||||
@@ -254,10 +254,7 @@ HttpBaseChannel::Init(nsIURI *aURI,
|
||||
int32_t port = -1;
|
||||
bool isHTTPS = false;
|
||||
|
||||
nsresult rv = mURI->SchemeIs("https", &isHTTPS);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mURI->GetAsciiHost(host);
|
||||
nsresult rv = mURI->GetAsciiHost(host);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Reject the URL if it doesn't specify a host
|
||||
@@ -284,7 +281,7 @@ HttpBaseChannel::Init(nsIURI *aURI,
|
||||
rv = mRequestHead.SetHeader(nsHttp::Host, hostLine);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = gHttpHandler->AddStandardRequestHeaders(&mRequestHead, isHTTPS, aContentPolicyType);
|
||||
rv = gHttpHandler->AddStandardRequestHeaders(&mRequestHead, aContentPolicyType);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoCString type;
|
||||
@@ -1084,9 +1081,7 @@ HttpBaseChannel::DoApplyContentConversions(nsIStreamListener* aNextListener,
|
||||
break;
|
||||
}
|
||||
|
||||
bool isHTTPS = false;
|
||||
mURI->SchemeIs("https", &isHTTPS);
|
||||
if (gHttpHandler->IsAcceptableEncoding(val, isHTTPS)) {
|
||||
if (gHttpHandler->IsAcceptableEncoding(val)) {
|
||||
nsCOMPtr<nsIStreamConverterService> serv;
|
||||
rv = gHttpHandler->GetStreamConverterService(getter_AddRefs(serv));
|
||||
|
||||
|
||||
@@ -475,7 +475,6 @@ nsHttpHandler::InitConnectionMgr()
|
||||
|
||||
nsresult
|
||||
nsHttpHandler::AddStandardRequestHeaders(nsHttpRequestHead *request,
|
||||
bool isSecure,
|
||||
nsContentPolicyType aContentPolicyType)
|
||||
{
|
||||
nsresult rv;
|
||||
@@ -522,15 +521,9 @@ nsHttpHandler::AddStandardRequestHeaders(nsHttpRequestHead *request,
|
||||
}
|
||||
|
||||
// Add the "Accept-Encoding" header
|
||||
if (isSecure) {
|
||||
rv = request->SetHeader(nsHttp::Accept_Encoding, mHttpsAcceptEncodings,
|
||||
false,
|
||||
nsHttpHeaderArray::eVarietyRequestDefault);
|
||||
} else {
|
||||
rv = request->SetHeader(nsHttp::Accept_Encoding, mHttpAcceptEncodings,
|
||||
false,
|
||||
nsHttpHeaderArray::eVarietyRequestDefault);
|
||||
}
|
||||
rv = request->SetHeader(nsHttp::Accept_Encoding, mAcceptEncodings,
|
||||
false,
|
||||
nsHttpHeaderArray::eVarietyRequestDefault);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// add the "Send Hint" header
|
||||
@@ -564,19 +557,15 @@ nsHttpHandler::AddConnectionHeader(nsHttpRequestHead *request,
|
||||
}
|
||||
|
||||
bool
|
||||
nsHttpHandler::IsAcceptableEncoding(const char *enc, bool isSecure)
|
||||
nsHttpHandler::IsAcceptableEncoding(const char *enc)
|
||||
{
|
||||
if (!enc)
|
||||
return false;
|
||||
|
||||
// we used to accept x-foo anytime foo was acceptable, but that's just
|
||||
// continuing bad behavior.. so limit it to known x-* patterns
|
||||
bool rv;
|
||||
if (isSecure) {
|
||||
rv = nsHttp::FindToken(mHttpsAcceptEncodings.get(), enc, HTTP_LWS ",") != nullptr;
|
||||
} else {
|
||||
rv = nsHttp::FindToken(mHttpAcceptEncodings.get(), enc, HTTP_LWS ",") != nullptr;
|
||||
}
|
||||
bool rv = nsHttp::FindToken(mAcceptEncodings.get(), enc, HTTP_LWS ",") != nullptr;
|
||||
|
||||
// gzip and deflate are inherently acceptable in modern HTTP - always
|
||||
// process them if a stream converter can also be found.
|
||||
if (!rv &&
|
||||
@@ -584,8 +573,8 @@ nsHttpHandler::IsAcceptableEncoding(const char *enc, bool isSecure)
|
||||
!PL_strcasecmp(enc, "x-gzip") || !PL_strcasecmp(enc, "x-deflate"))) {
|
||||
rv = true;
|
||||
}
|
||||
LOG(("nsHttpHandler::IsAceptableEncoding %s https=%d %d\n",
|
||||
enc, isSecure, rv));
|
||||
LOG(("nsHttpHandler::IsAceptableEncoding %s %d\n",
|
||||
enc, rv));
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -1337,16 +1326,7 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
|
||||
rv = prefs->GetCharPref(HTTP_PREF("accept-encoding"),
|
||||
getter_Copies(acceptEncodings));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
SetAcceptEncodings(acceptEncodings, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (PREF_CHANGED(HTTP_PREF("accept-encoding.secure"))) {
|
||||
nsXPIDLCString acceptEncodings;
|
||||
rv = prefs->GetCharPref(HTTP_PREF("accept-encoding.secure"),
|
||||
getter_Copies(acceptEncodings));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
SetAcceptEncodings(acceptEncodings, true);
|
||||
SetAcceptEncodings(acceptEncodings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1985,18 +1965,9 @@ nsHttpHandler::SetAccept(const char *aAccept, AcceptType aType)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHttpHandler::SetAcceptEncodings(const char *aAcceptEncodings, bool isSecure)
|
||||
nsHttpHandler::SetAcceptEncodings(const char *aAcceptEncodings)
|
||||
{
|
||||
if (isSecure) {
|
||||
mHttpsAcceptEncodings = aAcceptEncodings;
|
||||
} else {
|
||||
// use legacy list if a secure override is not specified
|
||||
mHttpAcceptEncodings = aAcceptEncodings;
|
||||
if (mHttpsAcceptEncodings.IsEmpty()) {
|
||||
mHttpsAcceptEncodings = aAcceptEncodings;
|
||||
}
|
||||
}
|
||||
|
||||
mAcceptEncodings = aAcceptEncodings;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -79,10 +79,10 @@ public:
|
||||
nsHttpHandler();
|
||||
|
||||
nsresult Init();
|
||||
nsresult AddStandardRequestHeaders(nsHttpRequestHead *, bool isSecure, nsContentPolicyType aContentPolicyType);
|
||||
nsresult AddStandardRequestHeaders(nsHttpRequestHead *, nsContentPolicyType aContentPolicyType);
|
||||
nsresult AddConnectionHeader(nsHttpRequestHead *,
|
||||
uint32_t capabilities);
|
||||
bool IsAcceptableEncoding(const char *encoding, bool isSecure);
|
||||
bool IsAcceptableEncoding(const char *encoding);
|
||||
|
||||
const nsAFlatCString &UserAgent();
|
||||
|
||||
@@ -401,7 +401,7 @@ private:
|
||||
|
||||
nsresult SetAccept(const char *, AcceptType aType);
|
||||
nsresult SetAcceptLanguages();
|
||||
nsresult SetAcceptEncodings(const char *, bool mIsSecure);
|
||||
nsresult SetAcceptEncodings(const char *);
|
||||
|
||||
nsresult InitConnectionMgr();
|
||||
|
||||
@@ -479,8 +479,7 @@ private:
|
||||
nsCString mAcceptStyle;
|
||||
nsCString mAcceptDefault;
|
||||
nsCString mAcceptLanguages;
|
||||
nsCString mHttpAcceptEncodings;
|
||||
nsCString mHttpsAcceptEncodings;
|
||||
nsCString mAcceptEncodings;
|
||||
|
||||
nsXPIDLCString mDefaultSocketType;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user