diff options
author | Moonchild <moonchild@palemoon.org> | 2021-07-09 21:18:36 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2021-07-10 13:00:14 +0000 |
commit | 5e6305573f0202ab75ce8ec18ae8ebce2d0d97f8 (patch) | |
tree | f67ca3885146aac99ec4916c142d3b4d7c702eae /netwerk | |
parent | 3163b3af18d8b8ffa7b8294f61602b0f0f27da2f (diff) | |
download | uxp-5e6305573f0202ab75ce8ec18ae8ebce2d0d97f8.tar.gz |
[network] Stop treating http and https as different for encoding schemes.
There is no reason to treat available encoding schemes for these protocols
differently.
Diffstat (limited to 'netwerk')
-rw-r--r-- | netwerk/protocol/http/HttpBaseChannel.cpp | 11 | ||||
-rw-r--r-- | netwerk/protocol/http/nsHttpHandler.cpp | 51 | ||||
-rw-r--r-- | netwerk/protocol/http/nsHttpHandler.h | 9 |
3 files changed, 18 insertions, 53 deletions
diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index f7040a4b4c..877915acb5 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -171,10 +171,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 @@ -201,7 +198,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; @@ -975,9 +972,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)); diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index e6443173a9..42c7b1a8fe 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -448,7 +448,6 @@ nsHttpHandler::InitConnectionMgr() nsresult nsHttpHandler::AddStandardRequestHeaders(nsHttpRequestHead *request, - bool isSecure, nsContentPolicyType aContentPolicyType) { nsresult rv; @@ -495,15 +494,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 @@ -537,19 +530,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 && @@ -557,8 +546,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; } @@ -1277,16 +1266,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); } } @@ -1912,18 +1892,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; } diff --git a/netwerk/protocol/http/nsHttpHandler.h b/netwerk/protocol/http/nsHttpHandler.h index 4f632e0784..c3f6290095 100644 --- a/netwerk/protocol/http/nsHttpHandler.h +++ b/netwerk/protocol/http/nsHttpHandler.h @@ -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(); @@ -398,7 +398,7 @@ private: nsresult SetAccept(const char *, AcceptType aType); nsresult SetAcceptLanguages(); - nsresult SetAcceptEncodings(const char *, bool mIsSecure); + nsresult SetAcceptEncodings(const char *); nsresult InitConnectionMgr(); @@ -476,8 +476,7 @@ private: nsCString mAcceptStyle; nsCString mAcceptDefault; nsCString mAcceptLanguages; - nsCString mHttpAcceptEncodings; - nsCString mHttpsAcceptEncodings; + nsCString mAcceptEncodings; nsXPIDLCString mDefaultSocketType; |