Bug Summary

File:root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp
Warning:line 816, column 5
Value stored to 'rv' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -O2 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name nsHttpHandler.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/netwerk/protocol/http -fcoverage-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/netwerk/protocol/http -resource-dir /usr/lib/llvm-23/lib/clang/23 -include /root/firefox-clang/config/gcc_hidden.h -include /root/firefox-clang/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -D _GLIBCXX_ASSERTIONS=1 -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -D MOZ_APP_UA_NAME="" -D MOZ_HAS_MOZGLUE -D MOZILLA_INTERNAL_API -D IMPL_LIBXUL -D MOZ_SUPPORT_LEAKCHECKING -D STATIC_EXPORTABLE_JS_API -I /root/firefox-clang/netwerk/protocol/http -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/netwerk/protocol/http -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/ipc/ipdl/_ipdlheaders -I /root/firefox-clang/ipc/chromium/src -I /root/firefox-clang/third_party/abseil-cpp -I /root/firefox-clang/dom/base -I /root/firefox-clang/netwerk/base -I /root/firefox-clang/netwerk/cookie -I /root/firefox-clang/netwerk/dns -I /root/firefox-clang/netwerk/ipc -I /root/firefox-clang/netwerk/socket/neqo_glue -I /root/firefox-clang/netwerk/url-classifier -I /root/firefox-clang/extensions/auth -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/c++/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/x86_64-linux-gnu/c++/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/c++/16/backward -internal-isystem /usr/lib/llvm-23/lib/clang/23/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-error=pessimizing-move -Wno-error=large-by-value-copy=128 -Wno-error=implicit-int-float-conversion -Wno-error=thread-safety-analysis -Wno-error=tautological-type-limit-compare -Wno-invalid-offsetof -Wno-range-loop-analysis -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -Wno-character-conversion -std=gnu++20 -fdeprecated-macro -ferror-limit 19 -fstrict-flex-arrays=1 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fno-rtti -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fno-sized-deallocation -fno-aligned-allocation -fdiagnostics-absolute-paths -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -mllvm -dwarf-linkage-names=Abstract -faddrsig -fdwarf2-cfi-asm -o /tmp/scan-build-2026-10-17-231001-351276-1 -x c++ /root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp
1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5// HttpLog.h should generally be included first
6#include "nsHttpHandler.h"
7
8#include <bitset>
9
10#include "ASpdySession.h"
11#include "AltServiceChild.h"
12#include "EventTokenBucket.h"
13#include "HttpLog.h"
14#include "LoadContextInfo.h"
15#include "SerializedLoadContext.h"
16#include "TRRServiceChannel.h"
17#include "Tickler.h"
18#include "mozilla/AntiTrackingRedirectHeuristic.h"
19#include "mozilla/AppShutdown.h"
20#include "mozilla/Base64.h"
21#include "mozilla/BasePrincipal.h"
22#include "mozilla/ClearOnShutdown.h"
23#include "mozilla/Components.h"
24#include "mozilla/DynamicFpiRedirectHeuristic.h"
25#include "mozilla/EndianUtils.h"
26#include "mozilla/LazyIdleThread.h"
27#include "mozilla/OriginAttributesHashKey.h"
28#include "mozilla/Printf.h"
29#include "mozilla/RandomNum.h"
30#include "mozilla/SHA1.h"
31#include "mozilla/ScopeExit.h"
32#include "mozilla/Sprintf.h"
33#include "mozilla/StaticPrefs_image.h"
34#include "mozilla/StaticPrefs_network.h"
35#include "mozilla/StaticPrefs_privacy.h"
36#include "mozilla/StaticPrefs_security.h"
37#include "mozilla/StoragePrincipalHelper.h"
38#include "mozilla/SyncRunnable.h"
39#include "mozilla/dom/ContentParent.h"
40#include "mozilla/dom/Navigator.h"
41#include "mozilla/dom/Promise.h"
42#include "mozilla/dom/network/Connection.h"
43#include "mozilla/glean/GleanPings.h"
44#include "mozilla/glean/NetwerkProtocolHttpMetrics.h"
45#include "mozilla/intl/LocaleService.h"
46#include "mozilla/ipc/URIUtils.h"
47#include "mozilla/net/HttpConnectionMgrParent.h"
48#include "mozilla/net/NeckoChild.h"
49#include "mozilla/net/NeckoParent.h"
50#include "mozilla/net/RequestContextService.h"
51#include "mozilla/net/SocketProcessChild.h"
52#include "mozilla/net/SocketProcessParent.h"
53#include "mozilla/net/rust_helper.h"
54#include "nsAsyncRedirectVerifyHelper.h"
55#include "nsCOMPtr.h"
56#include "nsCORSListenerProxy.h"
57#include "nsCRT.h"
58#include "nsCategoryManagerUtils.h"
59#include "nsCharSeparatedTokenizer.h"
60#include "nsComponentManagerUtils.h"
61#include "nsDirectoryServiceDefs.h"
62#include "nsError.h"
63#include "nsHTTPCompressConv.h"
64#include "nsHttp.h"
65#include "nsHttpAuthCache.h"
66#include "nsHttpChannel.h"
67#include "nsHttpChannelAuthProvider.h"
68#include "nsHttpConnectionMgr.h"
69#include "nsICookieService.h"
70#include "nsIHttpActivityObserver.h"
71#include "nsINetworkLinkService.h"
72#include "nsIOService.h"
73#include "nsIObserverService.h"
74#include "nsIParentalControlsService.h"
75#include "nsISiteIntegrityService.h"
76#include "nsISiteSecurityService.h"
77#include "nsISocketProvider.h"
78#include "nsIStreamConverterService.h"
79#include "nsISupportsPrimitives.h"
80#include "nsIXULAppInfo.h"
81#include "nsIXULRuntime.h"
82#include "nsNSSComponent.h"
83#include "nsNetCID.h"
84#include "nsNetUtil.h"
85#include "nsPIDOMWindow.h"
86#include "nsPrintfCString.h"
87#include "nsRFPService.h"
88#include "nsServiceManagerUtils.h"
89#include "nsSocketProviderService.h"
90#include "nsSocketTransportService2.h"
91#include "nsStandardURL.h"
92#include "prsystem.h"
93
94#if defined(XP_UNIX1)
95# include <sys/utsname.h>
96#endif
97
98#if defined(MOZ_WIDGET_GTK1)
99# include "mozilla/WidgetUtilsGtk.h"
100#endif
101
102#if defined(XP_WIN)
103# include <windows.h>
104
105# include "mozilla/WindowsVersion.h"
106#endif
107
108#if defined(XP_MACOSX)
109# include <CoreServices/CoreServices.h>
110#endif
111
112//-----------------------------------------------------------------------------
113#include "mozilla/net/HttpChannelChild.h"
114
115#define UA_PREF_PREFIX"general.useragent." "general.useragent."
116#ifdef XP_WIN
117# define UA_SPARE_PLATFORM
118#endif
119
120#define HTTP_PREF_PREFIX"network.http." "network.http."
121#define INTL_ACCEPT_LANGUAGES"intl.accept_languages" "intl.accept_languages"
122#define BROWSER_PREF_PREFIX"browser.cache." "browser.cache."
123#define H2MANDATORY_SUITE"security.ssl3.ecdhe_rsa_aes_128_gcm_sha256" "security.ssl3.ecdhe_rsa_aes_128_gcm_sha256"
124#define SAFE_HINT_HEADER_VALUE"safeHint.enabled" "safeHint.enabled"
125#define SECURITY_PREFIX"security." "security."
126#define DOM_SECURITY_PREFIX"dom.security" "dom.security"
127
128#define ACCEPT_HEADER_STYLE"text/css,*/*;q=0.1" "text/css,*/*;q=0.1"
129#define ACCEPT_HEADER_JSON"application/json,*/*;q=0.5" "application/json,*/*;q=0.5"
130#define ACCEPT_HEADER_TEXT"text/plain,*/*;q=0.5" "text/plain,*/*;q=0.5"
131#define ACCEPT_HEADER_ALL"*/*" "*/*"
132
133#define UA_PREF(_pref)"general.useragent." _pref UA_PREF_PREFIX"general.useragent." _pref
134#define HTTP_PREF(_pref)"network.http." _pref HTTP_PREF_PREFIX"network.http." _pref
135#define BROWSER_PREF(_pref)"browser.cache." _pref BROWSER_PREF_PREFIX"browser.cache." _pref
136
137#define NS_HTTP_PROTOCOL_FLAGS(URI_STD | ALLOWS_PROXY | ALLOWS_PROXY_HTTP | URI_LOADABLE_BY_ANYONE
)
\
138 (URI_STD | ALLOWS_PROXY | ALLOWS_PROXY_HTTP | URI_LOADABLE_BY_ANYONE)
139
140//-----------------------------------------------------------------------------
141
142using mozilla::dom::Promise;
143
144namespace mozilla::net {
145
146LazyLogModule gHttpLog("nsHttp");
147LazyLogModule gHttpIOLog("HttpIO");
148
149#ifdef ANDROID
150static nsCString GetDeviceModelId() {
151 // Assumed to be running on the main thread
152 // We need the device property in either case
153 nsAutoCString deviceModelId;
154 nsCOMPtr<nsIPropertyBag2> infoService;
155 infoService = mozilla::components::SystemInfo::Service();
156 MOZ_ASSERT(infoService, "Could not find a system info service")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(infoService)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(infoService))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("infoService" " ("
"Could not find a system info service" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 156); AnnotateMozCrashReason("MOZ_ASSERT" "(" "infoService"
") (" "Could not find a system info service" ")"); do { MOZ_CrashSequence
(__null, 156); __attribute__((nomerge)) ::abort(); } while (false
); } } while (false)
;
157 nsAutoString androidDevice;
158 nsresult rv = infoService->GetPropertyAsAString(u"device"_ns, androidDevice);
159 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
160 deviceModelId = NS_LossyConvertUTF16toASCII(androidDevice);
161 }
162 nsAutoCString deviceString;
163 rv = Preferences::GetCString(UA_PREF("device_string")"general.useragent." "device_string", deviceString);
164 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
165 deviceString.Trim(" ", true, true);
166 deviceString.ReplaceSubstring("%DEVICEID%"_ns, deviceModelId);
167 return std::move(deviceString);
168 }
169 return std::move(deviceModelId);
170}
171#endif
172
173#ifdef XP_UNIX1
174static bool IsRunningUnderUbuntuSnap() {
175# if defined(MOZ_WIDGET_GTK1)
176 if (!widget::IsRunningUnderSnap()) {
177 return false;
178 }
179
180 char version[100];
181 if (PR_GetSystemInfo(PR_SI_RELEASE_BUILD, version, sizeof(version)) ==
182 PR_SUCCESS) {
183 if (strstr(version, "Ubuntu")) {
184 return true;
185 }
186 }
187# endif
188 return false;
189}
190#endif
191
192//-----------------------------------------------------------------------------
193// nsHttpHandler <public>
194//-----------------------------------------------------------------------------
195
196StaticRefPtr<nsHttpHandler> gHttpHandler;
197
198/* static */
199already_AddRefed<nsHttpHandler> nsHttpHandler::GetInstance() {
200 if (!gHttpHandler) {
201 gHttpHandler = new nsHttpHandler();
202 DebugOnly<nsresult> rv = gHttpHandler->Init();
203 MOZ_ASSERT(NS_SUCCEEDED(rv))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)
)))>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)
))))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 203); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))"
")"); do { MOZ_CrashSequence(__null, 203); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
204 // There is code that may be executed during the final cycle collection
205 // shutdown and still referencing gHttpHandler. Not earlier than that:
206 // resolving an atom once the table is gone asserts.
207 RunOnShutdown(
208 [] {
209 gHttpHandler->Shutdown();
210 gHttpHandler = nullptr;
211 },
212 ShutdownPhase::CCPostLastCycleCollection);
213 }
214 RefPtr<nsHttpHandler> httpHandler = gHttpHandler;
215 return httpHandler.forget();
216}
217
218/// Derive the HTTP Accept header for image requests based on the enabled prefs
219/// for non-universal image types. This may be overridden in its entirety by
220/// the image.http.accept pref.
221static nsCString ImageAcceptHeader() {
222 nsCString mimeTypes;
223
224 mimeTypes.Append("image/avif,");
225
226#ifdef MOZ_JXL1
227 if (mozilla::StaticPrefs::image_jxl_enabled()) {
228 mimeTypes.Append("image/jxl,");
229 }
230#endif
231
232 mimeTypes.Append("image/webp,");
233
234 // Default value as specified by fetch standard
235 // https://fetch.spec.whatwg.org/commit-snapshots/8dd73dbecfefdbef8f432164fb3a5b9785f7f520/#ref-for-header-list-contains%E2%91%A7
236 mimeTypes.Append("image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5");
237
238 return mimeTypes;
239}
240
241static nsCString DocumentAcceptHeader() {
242 // https://fetch.spec.whatwg.org/#document-accept-header-value
243 // The value specified by the fetch standard is
244 // `text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8`
245 nsCString mimeTypes("text/html,application/xhtml+xml,application/xml;q=0.9,");
246
247 // we also insert all of the image formats before */* when the pref is set
248 if (mozilla::StaticPrefs::network_http_accept_include_images()) {
249 mimeTypes.Append("image/avif,");
250
251#ifdef MOZ_JXL1
252 if (mozilla::StaticPrefs::image_jxl_enabled()) {
253 mimeTypes.Append("image/jxl,");
254 }
255#endif
256
257 mimeTypes.Append("image/webp,image/png,image/svg+xml,");
258 }
259
260 mimeTypes.Append("*/*;q=0.8");
261
262 return mimeTypes;
263}
264
265Atomic<bool, Relaxed> nsHttpHandler::sParentalControlsEnabled(false);
266
267nsHttpHandler::nsHttpHandler()
268 : mAuthCache(new nsHttpAuthCache()),
269 mPrivateAuthCache(new nsHttpAuthCache()),
270 mIdleTimeout(PR_SecondsToInterval(10)),
271 mSpdyTimeout(
272 PR_SecondsToInterval(StaticPrefs::network_http_http2_timeout())),
273 mResponseTimeout(PR_SecondsToInterval(300)),
274 mImageAcceptHeader(ImageAcceptHeader()),
275 mDocumentAcceptHeader(DocumentAcceptHeader()),
276 mLastUniqueID(NowInSeconds()PRTimeToSeconds(PR_Now())),
277 mIdempotencyKeySeed(mozilla::RandomUint64OrDie()),
278 mPrivateBrowsingIdempotencyKeySeed(mozilla::RandomUint64OrDie()),
279 mDebugObservations(false),
280 mEnableAltSvc(false),
281 mSpdyPingThreshold(PR_SecondsToInterval(
282 StaticPrefs::network_http_http2_ping_threshold())),
283 mSpdyPingTimeout(PR_SecondsToInterval(
284 StaticPrefs::network_http_http2_ping_timeout())) {
285 LOG(("Creating nsHttpHandler [this=%p].\n", this))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "Creating nsHttpHandler [this=%p].\n"
, this); } } while (0)
;
286
287 mAuthCache->Init();
288 mPrivateAuthCache->Init();
289
290 mUserAgentOverride.SetIsVoid(true);
291
292 MOZ_ASSERT(!gHttpHandler, "HTTP handler already created!")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!gHttpHandler)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!gHttpHandler))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("!gHttpHandler" " ("
"HTTP handler already created!" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 292); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!gHttpHandler"
") (" "HTTP handler already created!" ")"); do { MOZ_CrashSequence
(__null, 292); __attribute__((nomerge)) ::abort(); } while (false
); } } while (false)
;
293
294 nsCOMPtr<nsIXULRuntime> runtime;
295 runtime = mozilla::components::XULRuntime::Service();
296 if (runtime) {
297 runtime->GetProcessID(&mProcessId);
298 runtime->GetUniqueProcessID(&mUniqueProcessId);
299 }
300}
301
302nsHttpHandler::~nsHttpHandler() {
303 LOG(("Deleting nsHttpHandler [this=%p]\n", this))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "Deleting nsHttpHandler [this=%p]\n"
, this); } } while (0)
;
304
305 // Note: don't call NeckoChild::DestroyNeckoChild() here, as it's too late
306 // and it'll segfault. NeckoChild will get cleaned up by process exit.
307
308 Shutdown();
309
310 mConnMgr = nullptr;
311}
312
313void nsHttpHandler::Shutdown() {
314 if (mShutdownCalled.exchange(true)) {
315 return;
316 }
317
318 LOG(("nsHttpHandler::Shutdown [this=%p]\n", this))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::Shutdown [this=%p]\n"
, this); } } while (0)
;
319
320 ShutdownConnectionManager();
321
322 nsHttp::DestroyAtomTable();
323}
324
325static const char* gCallbackPrefs[] = {
326 HTTP_PREF_PREFIX"network.http.",
327 UA_PREF_PREFIX"general.useragent.",
328 INTL_ACCEPT_LANGUAGES"intl.accept_languages",
329 BROWSER_PREF("disk_cache_ssl")"browser.cache." "disk_cache_ssl",
330 H2MANDATORY_SUITE"security.ssl3.ecdhe_rsa_aes_128_gcm_sha256",
331 HTTP_PREF("tcp_keepalive.short_lived_connections")"network.http." "tcp_keepalive.short_lived_connections",
332 HTTP_PREF("tcp_keepalive.long_lived_connections")"network.http." "tcp_keepalive.long_lived_connections",
333 SAFE_HINT_HEADER_VALUE"safeHint.enabled",
334 SECURITY_PREFIX"security.",
335 DOM_SECURITY_PREFIX"dom.security",
336 "image.http.accept",
337 "image.jxl.enabled",
338 nullptr,
339};
340
341nsresult nsHttpHandler::Init() {
342 nsresult rv;
343
344 LOG(("nsHttpHandler::Init\n"))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::Init\n"
); } } while (0)
;
345 MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(NS_IsMainThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 345); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()"
")"); do { MOZ_CrashSequence(__null, 345); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
346
347 // We should not create nsHttpHandler during shutdown, but we have some
348 // xpcshell tests doing this.
349 if (MOZ_UNLIKELY(AppShutdown::IsInOrBeyond(ShutdownPhase::AppShutdown) &&(__builtin_expect(!!(AppShutdown::IsInOrBeyond(ShutdownPhase::
AppShutdown) && !PR_GetEnv("XPCSHELL_TEST_PROFILE_DIR"
)), 0))
350 !PR_GetEnv("XPCSHELL_TEST_PROFILE_DIR"))(__builtin_expect(!!(AppShutdown::IsInOrBeyond(ShutdownPhase::
AppShutdown) && !PR_GetEnv("XPCSHELL_TEST_PROFILE_DIR"
)), 0))
) {
351 MOZ_DIAGNOSTIC_CRASH("Try to init HttpHandler after shutdown")do { do { } while (false); MOZ_ReportCrash("" "Try to init HttpHandler after shutdown"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 351); AnnotateMozCrashReason("MOZ_CRASH(" "Try to init HttpHandler after shutdown"
")"); do { MOZ_CrashSequence(__null, 351); __attribute__((nomerge
)) ::abort(); } while (false); } while (false)
;
352 return NS_ERROR_ILLEGAL_DURING_SHUTDOWN;
353 }
354
355 rv = nsHttp::CreateAtomTable();
356 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv;
357
358 nsCOMPtr<nsIIOService> service;
359 service = mozilla::components::IO::Service(&rv);
360 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
361 NS_WARNING("unable to continue without io service")NS_DebugBreak(NS_DEBUG_WARNING, "unable to continue without io service"
, nullptr, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 361)
;
362 return rv;
363 }
364 mIOService = new nsMainThreadPtrHolder<nsIIOService>(
365 "nsHttpHandler::mIOService", service);
366
367 gIOService->LaunchSocketProcess();
368
369 if (IsNeckoChild()) NeckoChild::InitNeckoChild();
370
371 InitUserAgentComponents();
372
373 // This preference is only used in parent process.
374 if (!IsNeckoChild()) {
375 if (XRE_IsParentProcess()) {
376 mDictionaryCache = DictionaryCache::GetInstance();
377 // mDictionaryCache can be null if shutdown has occurred
378
379 std::bitset<3> usageOfHTTPSRRPrefs;
380 usageOfHTTPSRRPrefs[0] = StaticPrefs::network_dns_upgrade_with_https_rr();
381 usageOfHTTPSRRPrefs[1] =
382 StaticPrefs::network_dns_use_https_rr_as_altsvc();
383 usageOfHTTPSRRPrefs[2] = StaticPrefs::network_dns_echconfig_enabled();
384 glean::networking::https_rr_prefs_usage.Set(
385 static_cast<uint32_t>(usageOfHTTPSRRPrefs.to_ulong()));
386 glean::networking::http3_enabled.Set(
387 StaticPrefs::network_http_http3_enable());
388 }
389
390 mActivityDistributor = components::HttpActivityDistributor::Service();
391
392 auto initQLogDir = [&]() {
393 if (!StaticPrefs::network_http_http3_enable_qlog()) {
394 return EmptyCString();
395 }
396
397 nsCOMPtr<nsIFile> qlogDir;
398 nsresult rv =
399 NS_GetSpecialDirectory(NS_OS_TEMP_DIR"TmpD", getter_AddRefs(qlogDir));
400 if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv
)), 0))), "NS_FAILED(rv)", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 400)
) {
401 return EmptyCString();
402 }
403
404 nsAutoCString dirName("qlog_");
405 dirName.AppendInt(mProcessId);
406 rv = qlogDir->AppendNative(dirName);
407 if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv
)), 0))), "NS_FAILED(rv)", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 407)
) {
408 return EmptyCString();
409 }
410
411 return qlogDir->HumanReadablePath();
412 };
413 mHttp3QlogDir = initQLogDir();
414
415 if (const char* origin = PR_GetEnv("MOZ_FORCE_QUIC_ON")) {
416 nsCCharSeparatedTokenizer tokens(nsDependentCString(origin), ':');
417 nsAutoCString host;
418 int32_t port = 443;
419 if (tokens.hasMoreTokens()) {
420 host = tokens.nextToken();
421 if (tokens.hasMoreTokens()) {
422 nsresult res;
423 int32_t tmp = tokens.nextToken().ToInteger(&res);
424 if (NS_SUCCEEDED(res)((bool)(__builtin_expect(!!(!NS_FAILED_impl(res)), 1)))) {
425 port = tmp;
426 }
427 }
428 auto map = mAltSvcMappingTemptativeMap.Lock();
429 map->InsertOrUpdate(
430 host, MakeUnique<nsCString>(nsPrintfCString("h3=:%d", port)));
431 }
432 }
433 }
434
435 // monitor some preference changes
436 Preferences::RegisterPrefixCallbacks(nsHttpHandler::PrefsChanged,
437 gCallbackPrefs, this);
438 PrefsChanged(nullptr);
439
440 mCompatFirefox.AssignLiteral("Firefox/" MOZILLA_UAVERSION"160.0");
441
442 nsCOMPtr<nsIXULAppInfo> appInfo;
443 appInfo = mozilla::components::XULRuntime::Service();
444
445 mAppName.AssignLiteral(MOZ_APP_UA_NAME"");
446 if (mAppName.Length() == 0 && appInfo) {
447 // Try to get the UA name from appInfo, falling back to the name
448 appInfo->GetUAName(mAppName);
449 if (mAppName.Length() == 0) {
450 appInfo->GetName(mAppName);
451 }
452 appInfo->GetVersion(mAppVersion);
453 mAppName.StripChars(R"( ()<>@,;:\"/[]?={})");
454 } else {
455 mAppVersion.AssignLiteral(MOZ_APP_UA_VERSION"160.0a1");
456 }
457
458 mMisc.AssignLiteral("rv:" MOZILLA_UAVERSION"160.0");
459
460 // Generate the spoofed User Agent for fingerprinting resistance.
461 nsRFPService::GetSpoofedUserAgent(mSpoofedUserAgent);
462
463 mSessionStartTime = NowInSeconds()PRTimeToSeconds(PR_Now());
464 mHandlerActive = true;
465
466 rv = InitConnectionMgr();
467 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv;
468
469 mAltSvcCache = MakeUnique<AltSvcCache>();
470
471 mRequestContextService = RequestContextService::GetOrCreate();
472
473#if defined(ANDROID) || defined(XP_IOS)
474 mProductSub.AssignLiteral(MOZILLA_UAVERSION"160.0");
475#else
476 mProductSub.AssignLiteral(LEGACY_UA_GECKO_TRAIL"20100101");
477#endif
478
479#if DEBUG1
480 // dump user agent prefs
481 LOG(("> legacy-app-name = %s\n", mLegacyAppName.get()))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "> legacy-app-name = %s\n"
, mLegacyAppName.get()); } } while (0)
;
482 LOG(("> legacy-app-version = %s\n", mLegacyAppVersion.get()))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "> legacy-app-version = %s\n"
, mLegacyAppVersion.get()); } } while (0)
;
483 LOG(("> platform = %s\n", mPlatform.get()))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "> platform = %s\n"
, mPlatform.get()); } } while (0)
;
484 LOG(("> oscpu = %s\n", mOscpu.get()))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "> oscpu = %s\n"
, mOscpu.get()); } } while (0)
;
485 LOG(("> misc = %s\n", mMisc.get()))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "> misc = %s\n"
, mMisc.get()); } } while (0)
;
486 LOG(("> product = %s\n", mProduct.get()))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "> product = %s\n"
, mProduct.get()); } } while (0)
;
487 LOG(("> product-sub = %s\n", mProductSub.get()))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "> product-sub = %s\n"
, mProductSub.get()); } } while (0)
;
488 LOG(("> app-name = %s\n", mAppName.get()))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "> app-name = %s\n"
, mAppName.get()); } } while (0)
;
489 LOG(("> app-version = %s\n", mAppVersion.get()))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "> app-version = %s\n"
, mAppVersion.get()); } } while (0)
;
490 LOG(("> compat-firefox = %s\n", mCompatFirefox.get()))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "> compat-firefox = %s\n"
, mCompatFirefox.get()); } } while (0)
;
491 LOG(("> user-agent = %s\n", UserAgent(false).get()))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "> user-agent = %s\n"
, UserAgent(false).get()); } } while (0)
;
492#endif
493
494 // Startup the http category
495 // Bring alive the objects in the http-protocol-startup category
496 NS_CreateServicesFromCategory(
497 NS_HTTP_STARTUP_CATEGORY"http-startup-category",
498 static_cast<nsISupports*>(static_cast<void*>(this)),
499 NS_HTTP_STARTUP_TOPIC"http-startup");
500
501 nsCOMPtr<nsIObserverService> obsService =
502 static_cast<nsIObserverService*>(gIOService);
503 if (obsService) {
504 // register the handler object as a weak callback as we don't need to worry
505 // about shutdown ordering.
506 obsService->AddObserver(this, "profile-change-net-teardown", true);
507 obsService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID"xpcom-shutdown", true);
508 obsService->AddObserver(this, "net:clear-active-logins", true);
509 obsService->AddObserver(this, "net:prune-dead-connections", true);
510 // Sent by the TorButton add-on in the Tor Browser
511 obsService->AddObserver(this, "net:prune-all-connections", true);
512 obsService->AddObserver(this, "net:cancel-all-connections", true);
513 obsService->AddObserver(this, "last-pb-context-exited", true);
514 obsService->AddObserver(this, "browser:purge-session-history", true);
515 obsService->AddObserver(this, NS_NETWORK_LINK_TOPIC"network:link-status-changed", true);
516 obsService->AddObserver(this, "application-background", true);
517 obsService->AddObserver(this, "psm:user-certificate-added", true);
518 obsService->AddObserver(this, "psm:user-certificate-deleted", true);
519 obsService->AddObserver(this, "intl:app-locales-changed", true);
520 obsService->AddObserver(this, "browser-delayed-startup-finished", true);
521 obsService->AddObserver(this, "network:reset-http3-excluded-list", true);
522 obsService->AddObserver(this, "network:socket-process-crashed", true);
523 obsService->AddObserver(this, "network:reset_third_party_roots_check",
524 true);
525 obsService->AddObserver(this, "idle-daily", true);
526
527 if (!IsNeckoChild()) {
528 obsService->AddObserver(this, "net:current-browser-id", true);
529 }
530
531 // disabled as its a nop right now
532 // obsService->AddObserver(this, "net:failed-to-process-uri-content", true);
533 }
534
535 MakeNewRequestTokenBucket();
536 mWifiTickler = new Tickler();
537 if (NS_FAILED(mWifiTickler->Init())((bool)(__builtin_expect(!!(NS_FAILED_impl(mWifiTickler->Init
())), 0)))
) {
538 mWifiTickler = nullptr;
539 }
540
541 UpdateParentalControlsEnabled(false /* wait for completion */);
542 return NS_OK;
543}
544
545void nsHttpHandler::UpdateParentalControlsEnabled(bool waitForCompletion) {
546 // Child process does not have privileges to read parentals control state
547 if (!XRE_IsParentProcess()) {
548 return;
549 }
550
551 auto getParentalControlsTask = []() {
552 nsCOMPtr<nsIParentalControlsService> pc =
553 do_CreateInstance("@mozilla.org/parental-controls-service;1");
554 if (pc) {
555 bool localEnabled = false;
556 pc->GetParentalControlsEnabled(&localEnabled);
557 sParentalControlsEnabled = localEnabled;
558
559 // Cache the state of parental controls via preference
560 if (!AppShutdown::IsInOrBeyond(ShutdownPhase::AppShutdownConfirmed)) {
561 Preferences::SetBool(
562 StaticPrefs::GetPrefName_network_parental_controls_cached_state(),
563 localEnabled);
564 }
565 }
566 };
567
568 if (waitForCompletion) {
569 getParentalControlsTask();
570 } else {
571 // To avoid blocking on determining parental controls state, used the cached
572 // pref until the runnable completes
573 sParentalControlsEnabled =
574 mozilla::StaticPrefs::network_parental_controls_cached_state();
575 (void)NS_DispatchToMainThreadQueue(
576 NS_NewRunnableFunction("GetParentalControlsEnabled",
577 std::move(getParentalControlsTask)),
578 mozilla::EventQueuePriority::Idle);
579 }
580}
581
582void nsHttpHandler::GenerateIdempotencyKeyForPost(const uint32_t aPostId,
583 nsILoadInfo* aLoadInfo,
584 nsACString& aOutKey) {
585 MOZ_ASSERT(aLoadInfo)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aLoadInfo)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aLoadInfo))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("aLoadInfo", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 585); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aLoadInfo" ")"
); do { MOZ_CrashSequence(__null, 585); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
586 OriginAttributes attrs = aLoadInfo->GetOriginAttributes();
587
588 // Create a SHA1 string using the origin attributes, session seed and the post
589 // id.
590 nsAutoCString sha1Input;
591 attrs.CreateSuffix(sha1Input);
592 sha1Input.AppendInt(aPostId);
593 sha1Input.AppendInt(attrs.IsPrivateBrowsing()
594 ? mPrivateBrowsingIdempotencyKeySeed
595 : mIdempotencyKeySeed);
596 SHA1Sum sha1;
597 SHA1Sum::Hash hash;
598 sha1.update((sha1Input.get()), sha1Input.Length());
599 sha1.finish(hash);
600 uint64_t hashValue = BigEndian::readUint64(&hash);
601
602 aOutKey.Append("\"");
603 aOutKey.AppendInt(hashValue);
604 aOutKey.Append("\"");
605}
606
607const nsCString& nsHttpHandler::Http3QlogDir() {
608 if (StaticPrefs::network_http_http3_enable_qlog()) {
609 return mHttp3QlogDir;
610 }
611
612 return EmptyCString();
613}
614
615void nsHttpHandler::MakeNewRequestTokenBucket() {
616 LOG(("nsHttpHandler::MakeNewRequestTokenBucket this=%p child=%d\n", this,do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::MakeNewRequestTokenBucket this=%p child=%d\n"
, this, IsNeckoChild()); } } while (0)
617 IsNeckoChild()))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::MakeNewRequestTokenBucket this=%p child=%d\n"
, this, IsNeckoChild()); } } while (0)
;
618 if (!mConnMgr || IsNeckoChild()) {
619 return;
620 }
621 RefPtr<EventTokenBucket> tokenBucket =
622 new EventTokenBucket(RequestTokenBucketHz(), RequestTokenBucketBurst());
623 // NOTE The thread or socket may be gone already.
624 nsresult rv = mConnMgr->UpdateRequestTokenBucket(tokenBucket);
625 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
626 LOG((" failed to update request token bucket\n"))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, " failed to update request token bucket\n"
); } } while (0)
;
627 }
628}
629
630nsresult nsHttpHandler::InitConnectionMgr() {
631 // Init ConnectionManager only on parent!
632 if (IsNeckoChild()) {
633 return NS_OK;
634 }
635
636 if (mConnMgr) {
637 return NS_OK;
638 }
639
640 if (nsIOService::UseSocketProcess(true) && XRE_IsParentProcess()) {
641 mConnMgr = new HttpConnectionMgrParent();
642 RefPtr<nsHttpHandler> self = this;
643 auto task = [self]() {
644 RefPtr<HttpConnectionMgrParent> parent =
645 self->mConnMgr->AsHttpConnectionMgrParent();
646 RefPtr<SocketProcessParent> socketParent =
647 SocketProcessParent::GetSingleton();
648 (void)socketParent->SendPHttpConnectionMgrConstructor(
649 parent,
650 HttpHandlerInitArgs(self->mLegacyAppName, self->mLegacyAppVersion,
651 self->mPlatform, self->mOscpu, self->mMisc,
652 self->mProduct, self->mProductSub, self->mAppName,
653 self->mAppVersion, self->mCompatFirefox,
654 self->mCompatDevice, self->mDeviceModelId));
655 };
656 gIOService->CallOrWaitForSocketProcess(std::move(task));
657 } else {
658 MOZ_ASSERT(XRE_IsSocketProcess() || !nsIOService::UseSocketProcess())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(XRE_IsSocketProcess() || !nsIOService::UseSocketProcess
())>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(XRE_IsSocketProcess() || !nsIOService::UseSocketProcess
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("XRE_IsSocketProcess() || !nsIOService::UseSocketProcess()",
"/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 658); AnnotateMozCrashReason("MOZ_ASSERT" "(" "XRE_IsSocketProcess() || !nsIOService::UseSocketProcess()"
")"); do { MOZ_CrashSequence(__null, 658); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
659 mConnMgr = new nsHttpConnectionMgr();
660 }
661
662 return mConnMgr->Init(mMaxUrgentExcessiveConns, mMaxConnections,
663 mMaxPersistentConnectionsPerServer,
664 mMaxPersistentConnectionsPerProxy, mMaxRequestDelay,
665 mThrottleEnabled, mThrottleSuspendFor,
666 mThrottleResumeFor, mThrottleHoldTime, mThrottleMaxTime,
667 mBeConservativeForProxy);
668}
669
670// We're using RequestOverride because this can get called when these are
671// set by Fetch from the old request. We need to pass a function pointer to
672// let GetDictionaryFor suspend the channel before starting the async
673// dictionary load.
674nsresult nsHttpHandler::AddAcceptAndDictionaryHeaders(
675 nsIURI* aURI, ExtContentPolicyType aType, nsHttpRequestHead* aRequest,
676 bool aSecure, nsHttpChannel* aChan, void (*aSuspend)(nsHttpChannel*),
677 const std::function<bool(bool, DictionaryCacheEntry*)>& aCallback) {
678 LOG(("Adding Dictionary headers"))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "Adding Dictionary headers"
); } } while (0)
;
679 auto guard = MakeScopeExit([&]() { (aCallback)(false, nullptr); });
680
681 nsresult rv = NS_OK;
682 // Add the "Accept-Encoding" header and possibly Dictionary headers
683 if (aSecure) {
684 // The dictionary info may require us to check the cache.
685 if (StaticPrefs::network_http_dictionaries_enable() && mDictionaryCache) {
686 // Note: this is async; the lambda can happen later
687 // aCallback will now be owned by GetDictionaryFor
688 guard.release();
689 RefPtr<LoadContextInfo> lci = GetLoadContextInfo(aChan);
690 mDictionaryCache->GetDictionaryFor(
691 aURI, aType, lci, aChan, aSuspend,
692 [self = RefPtr(this), aRequest, aCallback](
693 bool aNeedsResume, DictionaryCacheEntry* aDict) {
694 if (!aDict) {
695 // Accept-Encoding was already set in AddStandardHeaders
696 (aCallback)(aNeedsResume, nullptr);
697 return NS_OK;
698 }
699
700 nsAutoCStringN<64> encodedHash = ":"_ns + aDict->GetHash() + ":"_ns;
701
702 // We want to make sure that the cache entry doesn't disappear out
703 // from under us if we set the header, so do the callback to
704 // Prefetch() the entry before adding the headers (so we don't
705 // have to remove the headers if Prefetch() fails). It might fail
706 // if something is asynchronously Dooming the entry but the
707 // DictionaryCache hasn't been updated to remove the entry yet (or
708 // any other thing that were to desynchronize the DictionaryCache
709 // with the actual cache.
710 if ((aCallback)(aNeedsResume, aDict)) {
711 LOG_DICTIONARIES(do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gDictionaryLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "Setting Available-Dictionary: %s"
, encodedHash.get()); } } while (0)
712 ("Setting Available-Dictionary: %s", encodedHash.get()))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gDictionaryLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "Setting Available-Dictionary: %s"
, encodedHash.get()); } } while (0)
;
713 // Need to retain access to the dictionary until the request
714 // completes. Note that this includes if the dictionary we offered
715 // gets replaced by another request while we're waiting for a
716 // response; in that case we need to read in a copy of the
717 // dictionary into memory before overwriting it and store in dict
718 // temporarily.
719 aRequest->SetDictionary(aDict);
720
721 nsresult rv = aRequest->SetHeader(
722 nsHttp::Available_Dictionary, encodedHash, false,
723 nsHttpHeaderArray::eVarietyRequestOverride);
724 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
725 return rv;
726 }
727 if (!aDict->GetId().IsEmpty()) {
728 nsPrintfCString id("\"%s\"", aDict->GetId().get());
729 LOG_DICTIONARIES(("Setting Dictionary-Id: %s", id.get()))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gDictionaryLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "Setting Dictionary-Id: %s"
, id.get()); } } while (0)
;
730 rv = aRequest->SetHeader(
731 nsHttp::Dictionary_Id, id, false,
732 nsHttpHeaderArray::eVarietyRequestOverride);
733 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
734 return rv;
735 }
736 }
737 return aRequest->SetHeader(
738 nsHttp::Accept_Encoding, self->mDictionaryAcceptEncodings,
739 false, nsHttpHeaderArray::eVarietyRequestOverride);
740 } // else probably Prefetch failed
741 return NS_OK;
742 });
743 }
744 }
745 // guard may call aCallback here
746 return rv;
747}
748
749nsresult nsHttpHandler::AddStandardRequestHeaders(
750 nsHttpRequestHead* request, nsIURI* aURI, bool aIsHTTPS,
751 ExtContentPolicyType aContentPolicyType, bool aShouldResistFingerprinting,
752 const nsCString& aLanguageOverride) {
753 nsresult rv;
754
755 // Add the "User-Agent" header
756 rv = request->SetHeader(nsHttp::User_Agent,
757 UserAgent(aShouldResistFingerprinting), false,
758 nsHttpHeaderArray::eVarietyRequestDefault);
759 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv;
760
761 // MIME based content negotiation lives!
762 // Add the "Accept" header. Note, this is set as an override because the
763 // service worker expects to see it. The other "default" headers are
764 // hidden from service worker interception.
765 nsAutoCString accept;
766 if (aContentPolicyType == ExtContentPolicy::TYPE_DOCUMENT ||
767 aContentPolicyType == ExtContentPolicy::TYPE_SUBDOCUMENT) {
768 accept.Assign(mDocumentAcceptHeader);
769 } else if (aContentPolicyType == ExtContentPolicy::TYPE_IMAGE ||
770 aContentPolicyType == ExtContentPolicy::TYPE_IMAGESET) {
771 accept.Assign(mImageAcceptHeader);
772 } else if (aContentPolicyType == ExtContentPolicy::TYPE_STYLESHEET) {
773 accept.Assign(ACCEPT_HEADER_STYLE"text/css,*/*;q=0.1");
774 } else if (aContentPolicyType == ExtContentPolicy::TYPE_JSON) {
775 accept.Assign(ACCEPT_HEADER_JSON"application/json,*/*;q=0.5");
776 } else if (aContentPolicyType == ExtContentPolicy::TYPE_TEXT) {
777 accept.Assign(ACCEPT_HEADER_TEXT"text/plain,*/*;q=0.5");
778 } else {
779 accept.Assign(ACCEPT_HEADER_ALL"*/*");
780 }
781
782 rv = request->SetHeader(nsHttp::Accept, accept, false,
783 nsHttpHeaderArray::eVarietyRequestOverride);
784 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv;
785
786 if (!aLanguageOverride.IsEmpty()) {
787 nsAutoCString acceptLanguage;
788 acceptLanguage.Assign(aLanguageOverride.get());
789 rv = request->SetHeader(nsHttp::Accept_Language, acceptLanguage, false,
790 nsHttpHeaderArray::eVarietyRequestOverride);
791 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv;
792 } else {
793 // Add the "Accept-Language" header. This header is also exposed to the
794 // service worker.
795 if (mAcceptLanguagesIsDirty) {
796 rv = SetAcceptLanguages();
797 MOZ_ASSERT(NS_SUCCEEDED(rv))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)
)))>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)
))))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 797); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))"
")"); do { MOZ_CrashSequence(__null, 797); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
798 }
799
800 // Add the "Accept-Language" header
801 if (!mAcceptLanguages.IsEmpty()) {
802 rv = request->SetHeader(nsHttp::Accept_Language, mAcceptLanguages, false,
803 nsHttpHeaderArray::eVarietyRequestOverride);
804 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv;
805 }
806 }
807
808 // add the "Send Hint" header
809 if (mSafeHintEnabled || sParentalControlsEnabled) {
810 rv = request->SetHeader(nsHttp::Prefer, "safe"_ns, false,
811 nsHttpHeaderArray::eVarietyRequestDefault);
812 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv;
813 }
814
815 if (aIsHTTPS) {
816 rv = request->SetHeader(nsHttp::Accept_Encoding, mHttpsAcceptEncodings,
Value stored to 'rv' is never read
817 false, nsHttpHeaderArray::eVarietyRequestDefault);
818 } else {
819 rv = request->SetHeader(nsHttp::Accept_Encoding, mHttpAcceptEncodings,
820 false, nsHttpHeaderArray::eVarietyRequestDefault);
821 }
822 return NS_OK;
823}
824
825nsresult nsHttpHandler::AddConnectionHeader(nsHttpRequestHead* request,
826 uint32_t caps) {
827 // RFC2616 section 19.6.2 states that the "Connection: keep-alive"
828 // and "Keep-alive" request headers should not be sent by HTTP/1.1
829 // user-agents. But this is not a problem in practice, and the
830 // alternative proxy-connection is worse. see 570283
831
832 constexpr auto close = "close"_ns;
833 constexpr auto keepAlive = "keep-alive"_ns;
834
835 const nsLiteralCString* connectionType = &close;
836 if (caps & NS_HTTP_ALLOW_KEEPALIVE(1 << 0)) {
837 connectionType = &keepAlive;
838 }
839
840 return request->SetHeader(nsHttp::Connection, *connectionType);
841}
842
843bool nsHttpHandler::IsAcceptableEncoding(const char* enc, bool isSecure) {
844 if (!enc) return false;
845
846 // we used to accept x-foo anytime foo was acceptable, but that's just
847 // continuing bad behavior.. so limit it to known x-* patterns
848 bool rv;
849 if (isSecure) {
850 // Should be a superset of mAcceptEncodings (unless someone messes with
851 // prefs)
852 rv = nsHttp::FindToken(mDictionaryAcceptEncodings.get(), enc,
853 HTTP_LWS" \t" ",") != nullptr;
854 } else {
855 rv = nsHttp::FindToken(mHttpAcceptEncodings.get(), enc, HTTP_LWS" \t" ",") !=
856 nullptr;
857 }
858 // gzip and deflate are inherently acceptable in modern HTTP - always
859 // process them if a stream converter can also be found.
860 if (!rv &&
861 (!nsCRT::strcasecmp(enc, "gzip") || !nsCRT::strcasecmp(enc, "deflate") ||
862 !nsCRT::strcasecmp(enc, "x-gzip") ||
863 !nsCRT::strcasecmp(enc, "x-deflate"))) {
864 rv = true;
865 }
866 LOG(("nsHttpHandler::IsAceptableEncoding %s https=%d %d\n", enc, isSecure,do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::IsAceptableEncoding %s https=%d %d\n"
, enc, isSecure, rv); } } while (0)
867 rv))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::IsAceptableEncoding %s https=%d %d\n"
, enc, isSecure, rv); } } while (0)
;
868 return rv;
869}
870
871nsISiteIntegrityService* nsHttpHandler::GetSiteIntegrityService() {
872 if (!mSiteIntegrityService) {
873 nsCOMPtr<nsISiteIntegrityService> service;
874 service = mozilla::components::SiteIntegrity::Service();
875 mSiteIntegrityService = new nsMainThreadPtrHolder<nsISiteIntegrityService>(
876 "nsHttpHandler::mSiteIntegrityService", service);
877 }
878 return mSiteIntegrityService;
879}
880
881nsISiteSecurityService* nsHttpHandler::GetSSService() {
882 if (!mSSService) {
883 nsCOMPtr<nsISiteSecurityService> service;
884 service = mozilla::components::SiteSecurity::Service();
885 mSSService = new nsMainThreadPtrHolder<nsISiteSecurityService>(
886 "nsHttpHandler::mSSService", service);
887 }
888 return mSSService;
889}
890
891nsICookieService* nsHttpHandler::GetCookieService() {
892 if (!mCookieService) {
893 nsCOMPtr<nsICookieService> service =
894 do_GetService(NS_COOKIESERVICE_CONTRACTID"@mozilla.org/cookieService;1");
895 mCookieService = new nsMainThreadPtrHolder<nsICookieService>(
896 "nsHttpHandler::mCookieService", service);
897 }
898 return mCookieService;
899}
900
901nsresult nsHttpHandler::GetIOService(nsIIOService** result) {
902 NS_ENSURE_ARG_POINTER(result)do { if ((__builtin_expect(!!(!(result)), 0))) { NS_DebugBreak
(NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "result" ") failed", nullptr
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 902); return NS_ERROR_INVALID_POINTER; } } while (false)
;
903
904 *result = do_AddRef(mIOService.get()).take();
905 return NS_OK;
906}
907
908void nsHttpHandler::NotifyObservers(nsIChannel* chan, const char* event) {
909 LOG(("nsHttpHandler::NotifyObservers [this=%p chan=%p event=\"%s\"]\n", this,do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::NotifyObservers [this=%p chan=%p event=\"%s\"]\n"
, this, chan, event); } } while (0)
910 chan, event))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::NotifyObservers [this=%p chan=%p event=\"%s\"]\n"
, this, chan, event); } } while (0)
;
911 nsCOMPtr<nsIObserverService> obsService = services::GetObserverService();
912 if (obsService) obsService->NotifyObservers(chan, event, nullptr);
913}
914
915nsresult nsHttpHandler::AsyncOnChannelRedirect(
916 nsIChannel* oldChan, nsIChannel* newChan, uint32_t flags,
917 nsIEventTarget* mainThreadEventTarget) {
918 MOZ_ASSERT(NS_IsMainThread() && (oldChan && newChan))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(NS_IsMainThread() && (oldChan && newChan
))>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(NS_IsMainThread() && (oldChan && newChan
)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("NS_IsMainThread() && (oldChan && newChan)",
"/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 918); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread() && (oldChan && newChan)"
")"); do { MOZ_CrashSequence(__null, 918); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
919
920 nsCOMPtr<nsIURI> oldURI;
921 oldChan->GetURI(getter_AddRefs(oldURI));
922 MOZ_ASSERT(oldURI)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(oldURI)>::isValid, "invalid assertion condition")
; if ((__builtin_expect(!!(!(!!(oldURI))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("oldURI", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 922); AnnotateMozCrashReason("MOZ_ASSERT" "(" "oldURI" ")")
; do { MOZ_CrashSequence(__null, 922); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
923
924 nsCOMPtr<nsIURI> newURI;
925 newChan->GetURI(getter_AddRefs(newURI));
926 MOZ_ASSERT(newURI)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(newURI)>::isValid, "invalid assertion condition")
; if ((__builtin_expect(!!(!(!!(newURI))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("newURI", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 926); AnnotateMozCrashReason("MOZ_ASSERT" "(" "newURI" ")")
; do { MOZ_CrashSequence(__null, 926); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
927
928 PrepareForAntiTrackingRedirectHeuristic(oldChan, oldURI, newChan, newURI);
929
930 DynamicFpiRedirectHeuristic(oldChan, oldURI, newChan, newURI);
931
932 // TODO E10S This helper has to be initialized on the other process
933 RefPtr<nsAsyncRedirectVerifyHelper> redirectCallbackHelper =
934 new nsAsyncRedirectVerifyHelper();
935
936 return redirectCallbackHelper->Init(oldChan, newChan, flags,
937 mainThreadEventTarget);
938}
939
940/* static */
941nsresult nsHttpHandler::GenerateHostPort(const nsCString& host, int32_t port,
942 nsACString& hostLine) {
943 return NS_GenerateHostPort(host, port, hostLine);
944}
945
946// static
947uint8_t nsHttpHandler::UrgencyFromCoSFlags(uint32_t cos,
948 int32_t aSupportsPriority) {
949 uint8_t urgency;
950 if (cos & nsIClassOfService::UrgentStart) {
951 // coming from an user interaction => response should be the highest
952 // priority
953 urgency = 1;
954 } else if (cos & nsIClassOfService::Leader) {
955 // main html document normal priority
956 urgency = 2;
957 } else if (cos & nsIClassOfService::Unblocked) {
958 urgency = 3;
959 } else if (cos & nsIClassOfService::Follower) {
960 urgency = 4;
961 } else if (cos & nsIClassOfService::Speculative) {
962 urgency = 6;
963 } else if (cos & nsIClassOfService::Background) {
964 // background tasks can be deprioritzed to the lowest priority
965 urgency = 6;
966 } else if (cos & nsIClassOfService::Tail) {
967 urgency = mozilla::StaticPrefs::network_http_tailing_urgency();
968 } else {
969 // all others get a lower priority than the main html document
970 urgency = 4;
971 }
972
973 int8_t adjustment = 0;
974 if (mozilla::StaticPrefs::network_fetchpriority_adjust_urgency()) {
975 if (aSupportsPriority <= nsISupportsPriority::PRIORITY_HIGHEST) {
976 adjustment = -2;
977 } else if (aSupportsPriority <= nsISupportsPriority::PRIORITY_HIGH) {
978 adjustment = -1;
979 } else if (aSupportsPriority >= nsISupportsPriority::PRIORITY_LOWEST) {
980 adjustment = 2;
981 } else if (aSupportsPriority >= nsISupportsPriority::PRIORITY_LOW) {
982 adjustment = 1;
983 }
984 }
985
986 auto adjustUrgency = [](uint8_t u, int8_t a) -> uint8_t {
987 int16_t result = static_cast<int16_t>(u) + a;
988 if (result <= 0) {
989 return 0;
990 }
991 if (result >= 6) {
992 return 6;
993 }
994 return result;
995 };
996
997 return adjustUrgency(urgency, adjustment);
998}
999
1000//-----------------------------------------------------------------------------
1001// nsHttpHandler <private>
1002//-----------------------------------------------------------------------------
1003
1004const nsCString& nsHttpHandler::UserAgent(bool aShouldResistFingerprinting) {
1005 if (aShouldResistFingerprinting && !mSpoofedUserAgent.IsEmpty()) {
1006 LOG(("using spoofed userAgent : %s\n", mSpoofedUserAgent.get()))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "using spoofed userAgent : %s\n"
, mSpoofedUserAgent.get()); } } while (0)
;
1007 return mSpoofedUserAgent;
1008 }
1009
1010 if (!mUserAgentOverride.IsVoid()) {
1011 LOG(("using general.useragent.override : %s\n", mUserAgentOverride.get()))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "using general.useragent.override : %s\n"
, mUserAgentOverride.get()); } } while (0)
;
1012 return mUserAgentOverride;
1013 }
1014
1015 if (mUserAgentIsDirty) {
1016 BuildUserAgent();
1017 mUserAgentIsDirty = false;
1018 }
1019
1020 return mUserAgent;
1021}
1022
1023void nsHttpHandler::BuildUserAgent() {
1024 LOG(("nsHttpHandler::BuildUserAgent\n"))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::BuildUserAgent\n"
); } } while (0)
;
1025
1026 MOZ_ASSERT(!mLegacyAppName.IsEmpty() && !mLegacyAppVersion.IsEmpty(),do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!mLegacyAppName.IsEmpty() && !mLegacyAppVersion
.IsEmpty())>::isValid, "invalid assertion condition"); if (
(__builtin_expect(!!(!(!!(!mLegacyAppName.IsEmpty() &&
!mLegacyAppVersion.IsEmpty()))), 0))) { do { } while (false)
; MOZ_ReportAssertionFailure("!mLegacyAppName.IsEmpty() && !mLegacyAppVersion.IsEmpty()"
" (" "HTTP cannot send practical requests without this much"
")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 1027); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mLegacyAppName.IsEmpty() && !mLegacyAppVersion.IsEmpty()"
") (" "HTTP cannot send practical requests without this much"
")"); do { MOZ_CrashSequence(__null, 1027); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
1027 "HTTP cannot send practical requests without this much")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!mLegacyAppName.IsEmpty() && !mLegacyAppVersion
.IsEmpty())>::isValid, "invalid assertion condition"); if (
(__builtin_expect(!!(!(!!(!mLegacyAppName.IsEmpty() &&
!mLegacyAppVersion.IsEmpty()))), 0))) { do { } while (false)
; MOZ_ReportAssertionFailure("!mLegacyAppName.IsEmpty() && !mLegacyAppVersion.IsEmpty()"
" (" "HTTP cannot send practical requests without this much"
")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 1027); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mLegacyAppName.IsEmpty() && !mLegacyAppVersion.IsEmpty()"
") (" "HTTP cannot send practical requests without this much"
")"); do { MOZ_CrashSequence(__null, 1027); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1028
1029 // preallocate to worst-case size, which should always be better
1030 // than if we didn't preallocate at all.
1031 mUserAgent.SetCapacity(mLegacyAppName.Length() + mLegacyAppVersion.Length() +
1032#ifndef UA_SPARE_PLATFORM
1033 mPlatform.Length() +
1034#endif
1035 mOscpu.Length() + mMisc.Length() + mProduct.Length() +
1036 mProductSub.Length() + mAppName.Length() +
1037 mAppVersion.Length() + mCompatFirefox.Length() +
1038 mCompatDevice.Length() + mDeviceModelId.Length() + 13);
1039
1040 // Application portion
1041 mUserAgent.Assign(mLegacyAppName);
1042 mUserAgent += '/';
1043 mUserAgent += mLegacyAppVersion;
1044 mUserAgent += ' ';
1045
1046 // Application comment
1047 mUserAgent += '(';
1048#ifndef UA_SPARE_PLATFORM
1049 if (!mPlatform.IsEmpty()) {
1050 mUserAgent += mPlatform;
1051 mUserAgent.AppendLiteral("; ");
1052 }
1053#endif
1054 if (!mCompatDevice.IsEmpty()) {
1055 mUserAgent += mCompatDevice;
1056 mUserAgent.AppendLiteral("; ");
1057 } else if (!mOscpu.IsEmpty()) {
1058 mUserAgent += mOscpu;
1059 mUserAgent.AppendLiteral("; ");
1060 }
1061 if (!mDeviceModelId.IsEmpty()) {
1062 mUserAgent += mDeviceModelId;
1063 mUserAgent.AppendLiteral("; ");
1064 }
1065 mUserAgent += mMisc;
1066 mUserAgent += ')';
1067
1068 // Product portion
1069 mUserAgent += ' ';
1070 mUserAgent += mProduct;
1071 mUserAgent += '/';
1072 mUserAgent += mProductSub;
1073
1074 bool isFirefox = mAppName.EqualsLiteral("Firefox");
1075 if (isFirefox || mCompatFirefoxEnabled) {
1076 // "Firefox/x.y" (compatibility) app token
1077 mUserAgent += ' ';
1078 mUserAgent += mCompatFirefox;
1079 }
1080 if (!isFirefox) {
1081 // App portion
1082 mUserAgent += ' ';
1083 mUserAgent += mAppName;
1084 mUserAgent += '/';
1085 mUserAgent += mAppVersion;
1086 }
1087}
1088
1089#ifdef XP_WIN
1090// Hardcode the reported Windows version to 10.0. This way, Microsoft doesn't
1091// get to change Web compat-sensitive values without our veto. The compat-
1092// sensitivity keeps going up as 10.0 stays as the current value for longer
1093// and longer. If the system-reported version ever changes, we'll be able to
1094// take our time to evaluate the Web compat impact instead of having to
1095// scramble to react like happened with macOS changing from 10.x to 11.x.
1096# define OSCPU_WINDOWS "Windows NT 10.0"
1097# define OSCPU_WIN64 OSCPU_WINDOWS "; Win64; x64"
1098#endif
1099
1100void nsHttpHandler::InitUserAgentComponents() {
1101 // Don't build user agent components in socket process, since the system info
1102 // is not available.
1103 if (XRE_IsSocketProcess()) {
1104 mUserAgentIsDirty = true;
1105 return;
1106 }
1107
1108 // Gather platform.
1109 mPlatform.AssignLiteral(
1110#if defined(ANDROID)
1111 "Android"
1112#elif defined(XP_WIN)
1113 "Windows"
1114#elif defined(XP_MACOSX)
1115 "Macintosh"
1116#elif defined(XP_IOS)
1117 "iPhone"
1118#elif defined(XP_UNIX1)
1119 // We historically have always had X11 here,
1120 // and there seems little a webpage can sensibly do
1121 // based on it being something else, so use X11 for
1122 // backwards compatibility in all cases.
1123 "X11"
1124#endif
1125 );
1126
1127#ifdef XP_UNIX1
1128 if (IsRunningUnderUbuntuSnap()) {
1129 mPlatform.AppendLiteral("; Ubuntu");
1130 }
1131#endif
1132
1133#ifdef ANDROID
1134 nsCOMPtr<nsIPropertyBag2> infoService;
1135 infoService = mozilla::components::SystemInfo::Service();
1136 MOZ_ASSERT(infoService, "Could not find a system info service")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(infoService)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(infoService))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("infoService" " ("
"Could not find a system info service" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 1136); AnnotateMozCrashReason("MOZ_ASSERT" "(" "infoService"
") (" "Could not find a system info service" ")"); do { MOZ_CrashSequence
(__null, 1136); __attribute__((nomerge)) ::abort(); } while (
false); } } while (false)
;
1137 nsresult rv;
1138
1139 // Add the Android version number to the Fennec platform identifier.
1140 nsAutoString androidVersion;
1141 rv = infoService->GetPropertyAsAString(u"release_version"_ns, androidVersion);
1142 MOZ_ASSERT_IF(do { if (((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)
))) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype((androidVersion.Length() == 1 && std::isdigit
(androidVersion[0])) || (androidVersion.Length() >= 2 &&
std::isdigit(androidVersion[0]) && (androidVersion[1
] == u'.' || std::isdigit(androidVersion[1]))))>::isValid,
"invalid assertion condition"); if ((__builtin_expect(!!(!(!
!((androidVersion.Length() == 1 && std::isdigit(androidVersion
[0])) || (androidVersion.Length() >= 2 && std::isdigit
(androidVersion[0]) && (androidVersion[1] == u'.' || std
::isdigit(androidVersion[1])))))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("(androidVersion.Length() == 1 && std::isdigit(androidVersion[0])) || (androidVersion.Length() >= 2 && std::isdigit(androidVersion[0]) && (androidVersion[1] == u'.' || std::isdigit(androidVersion[1])))"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 1148); AnnotateMozCrashReason("MOZ_ASSERT" "(" "(androidVersion.Length() == 1 && std::isdigit(androidVersion[0])) || (androidVersion.Length() >= 2 && std::isdigit(androidVersion[0]) && (androidVersion[1] == u'.' || std::isdigit(androidVersion[1])))"
")"); do { MOZ_CrashSequence(__null, 1148); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
1143 NS_SUCCEEDED(rv),do { if (((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)
))) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype((androidVersion.Length() == 1 && std::isdigit
(androidVersion[0])) || (androidVersion.Length() >= 2 &&
std::isdigit(androidVersion[0]) && (androidVersion[1
] == u'.' || std::isdigit(androidVersion[1]))))>::isValid,
"invalid assertion condition"); if ((__builtin_expect(!!(!(!
!((androidVersion.Length() == 1 && std::isdigit(androidVersion
[0])) || (androidVersion.Length() >= 2 && std::isdigit
(androidVersion[0]) && (androidVersion[1] == u'.' || std
::isdigit(androidVersion[1])))))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("(androidVersion.Length() == 1 && std::isdigit(androidVersion[0])) || (androidVersion.Length() >= 2 && std::isdigit(androidVersion[0]) && (androidVersion[1] == u'.' || std::isdigit(androidVersion[1])))"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 1148); AnnotateMozCrashReason("MOZ_ASSERT" "(" "(androidVersion.Length() == 1 && std::isdigit(androidVersion[0])) || (androidVersion.Length() >= 2 && std::isdigit(androidVersion[0]) && (androidVersion[1] == u'.' || std::isdigit(androidVersion[1])))"
")"); do { MOZ_CrashSequence(__null, 1148); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
1144 // Like version "9"do { if (((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)
))) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype((androidVersion.Length() == 1 && std::isdigit
(androidVersion[0])) || (androidVersion.Length() >= 2 &&
std::isdigit(androidVersion[0]) && (androidVersion[1
] == u'.' || std::isdigit(androidVersion[1]))))>::isValid,
"invalid assertion condition"); if ((__builtin_expect(!!(!(!
!((androidVersion.Length() == 1 && std::isdigit(androidVersion
[0])) || (androidVersion.Length() >= 2 && std::isdigit
(androidVersion[0]) && (androidVersion[1] == u'.' || std
::isdigit(androidVersion[1])))))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("(androidVersion.Length() == 1 && std::isdigit(androidVersion[0])) || (androidVersion.Length() >= 2 && std::isdigit(androidVersion[0]) && (androidVersion[1] == u'.' || std::isdigit(androidVersion[1])))"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 1148); AnnotateMozCrashReason("MOZ_ASSERT" "(" "(androidVersion.Length() == 1 && std::isdigit(androidVersion[0])) || (androidVersion.Length() >= 2 && std::isdigit(androidVersion[0]) && (androidVersion[1] == u'.' || std::isdigit(androidVersion[1])))"
")"); do { MOZ_CrashSequence(__null, 1148); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
1145 (androidVersion.Length() == 1 && std::isdigit(androidVersion[0])) ||do { if (((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)
))) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype((androidVersion.Length() == 1 && std::isdigit
(androidVersion[0])) || (androidVersion.Length() >= 2 &&
std::isdigit(androidVersion[0]) && (androidVersion[1
] == u'.' || std::isdigit(androidVersion[1]))))>::isValid,
"invalid assertion condition"); if ((__builtin_expect(!!(!(!
!((androidVersion.Length() == 1 && std::isdigit(androidVersion
[0])) || (androidVersion.Length() >= 2 && std::isdigit
(androidVersion[0]) && (androidVersion[1] == u'.' || std
::isdigit(androidVersion[1])))))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("(androidVersion.Length() == 1 && std::isdigit(androidVersion[0])) || (androidVersion.Length() >= 2 && std::isdigit(androidVersion[0]) && (androidVersion[1] == u'.' || std::isdigit(androidVersion[1])))"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 1148); AnnotateMozCrashReason("MOZ_ASSERT" "(" "(androidVersion.Length() == 1 && std::isdigit(androidVersion[0])) || (androidVersion.Length() >= 2 && std::isdigit(androidVersion[0]) && (androidVersion[1] == u'.' || std::isdigit(androidVersion[1])))"
")"); do { MOZ_CrashSequence(__null, 1148); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
1146 // Or like version "8.1", "10", or "12.1"do { if (((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)
))) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype((androidVersion.Length() == 1 && std::isdigit
(androidVersion[0])) || (androidVersion.Length() >= 2 &&
std::isdigit(androidVersion[0]) && (androidVersion[1
] == u'.' || std::isdigit(androidVersion[1]))))>::isValid,
"invalid assertion condition"); if ((__builtin_expect(!!(!(!
!((androidVersion.Length() == 1 && std::isdigit(androidVersion
[0])) || (androidVersion.Length() >= 2 && std::isdigit
(androidVersion[0]) && (androidVersion[1] == u'.' || std
::isdigit(androidVersion[1])))))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("(androidVersion.Length() == 1 && std::isdigit(androidVersion[0])) || (androidVersion.Length() >= 2 && std::isdigit(androidVersion[0]) && (androidVersion[1] == u'.' || std::isdigit(androidVersion[1])))"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 1148); AnnotateMozCrashReason("MOZ_ASSERT" "(" "(androidVersion.Length() == 1 && std::isdigit(androidVersion[0])) || (androidVersion.Length() >= 2 && std::isdigit(androidVersion[0]) && (androidVersion[1] == u'.' || std::isdigit(androidVersion[1])))"
")"); do { MOZ_CrashSequence(__null, 1148); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
1147 (androidVersion.Length() >= 2 && std::isdigit(androidVersion[0]) &&do { if (((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)
))) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype((androidVersion.Length() == 1 && std::isdigit
(androidVersion[0])) || (androidVersion.Length() >= 2 &&
std::isdigit(androidVersion[0]) && (androidVersion[1
] == u'.' || std::isdigit(androidVersion[1]))))>::isValid,
"invalid assertion condition"); if ((__builtin_expect(!!(!(!
!((androidVersion.Length() == 1 && std::isdigit(androidVersion
[0])) || (androidVersion.Length() >= 2 && std::isdigit
(androidVersion[0]) && (androidVersion[1] == u'.' || std
::isdigit(androidVersion[1])))))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("(androidVersion.Length() == 1 && std::isdigit(androidVersion[0])) || (androidVersion.Length() >= 2 && std::isdigit(androidVersion[0]) && (androidVersion[1] == u'.' || std::isdigit(androidVersion[1])))"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 1148); AnnotateMozCrashReason("MOZ_ASSERT" "(" "(androidVersion.Length() == 1 && std::isdigit(androidVersion[0])) || (androidVersion.Length() >= 2 && std::isdigit(androidVersion[0]) && (androidVersion[1] == u'.' || std::isdigit(androidVersion[1])))"
")"); do { MOZ_CrashSequence(__null, 1148); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
1148 (androidVersion[1] == u'.' || std::isdigit(androidVersion[1]))))do { if (((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)
))) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype((androidVersion.Length() == 1 && std::isdigit
(androidVersion[0])) || (androidVersion.Length() >= 2 &&
std::isdigit(androidVersion[0]) && (androidVersion[1
] == u'.' || std::isdigit(androidVersion[1]))))>::isValid,
"invalid assertion condition"); if ((__builtin_expect(!!(!(!
!((androidVersion.Length() == 1 && std::isdigit(androidVersion
[0])) || (androidVersion.Length() >= 2 && std::isdigit
(androidVersion[0]) && (androidVersion[1] == u'.' || std
::isdigit(androidVersion[1])))))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("(androidVersion.Length() == 1 && std::isdigit(androidVersion[0])) || (androidVersion.Length() >= 2 && std::isdigit(androidVersion[0]) && (androidVersion[1] == u'.' || std::isdigit(androidVersion[1])))"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 1148); AnnotateMozCrashReason("MOZ_ASSERT" "(" "(androidVersion.Length() == 1 && std::isdigit(androidVersion[0])) || (androidVersion.Length() >= 2 && std::isdigit(androidVersion[0]) && (androidVersion[1] == u'.' || std::isdigit(androidVersion[1])))"
")"); do { MOZ_CrashSequence(__null, 1148); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
1149
1150 // Normalize: strip any minor-version suffix (everything from the first '.'
1151 // onward, including the '.'). Some OEM firmwares report Build.VERSION.RELEASE
1152 // as e.g. "14.0" while stock AOSP reports "14"; that variance splits the
1153 // population into fingerprintable subsets without conveying any useful
1154 // information about the OS. Bug 2043395.
1155 int32_t dotIdx = androidVersion.FindChar(u'.');
1156 if (dotIdx >= 0) {
1157 androidVersion.Truncate(dotIdx);
1158 }
1159
1160 // Spoof version "Android 10" for Android OS versions < 10 to reduce their
1161 // fingerprintable user information. For Android OS versions >= 10, report
1162 // the real OS version because some enterprise websites only want to permit
1163 // clients with recent OS version (like bug 1876742). After the truncation
1164 // above, all versions are bare integers; two digits means the version is
1165 // >= 10.
1166 mPlatform += " ";
1167 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && androidVersion.Length() >= 2 &&
1168 std::isdigit(androidVersion[0]) && std::isdigit(androidVersion[1])) {
1169 mPlatform += NS_LossyConvertUTF16toASCII(androidVersion);
1170 } else {
1171 mPlatform.AppendLiteral("10");
1172 }
1173
1174 // Add the `Mobile` or `TV` token when running on device.
1175 bool isTV;
1176 rv = infoService->GetPropertyAsBool(u"tv"_ns, &isTV);
1177 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && isTV) {
1178 mCompatDevice.AssignLiteral("TV");
1179 } else {
1180 mCompatDevice.AssignLiteral("Mobile");
1181 }
1182
1183 if (Preferences::GetBool(UA_PREF("use_device")"general.useragent." "use_device", false)) {
1184 mDeviceModelId = mozilla::net::GetDeviceModelId();
1185 }
1186#endif // ANDROID
1187
1188#if defined(XP_IOS)
1189 // Freeze the iOS version to 18.0, use an underscore separator to avoid
1190 // detection as macOS.
1191 mCompatDevice.AssignLiteral("CPU iPhone OS 18_0 like Mac OS X");
1192#endif
1193
1194 // Gather OS/CPU.
1195#if defined(XP_WIN)
1196
1197# if defined _M_X64 || defined _M_AMD64
1198 mOscpu.AssignLiteral(OSCPU_WIN64);
1199# elif defined(_ARM64_)
1200 // Report ARM64 Windows 11+ as x86_64 and Windows 10 as x86. Windows 11+
1201 // supports x86_64 emulation, but Windows 10 only supports x86 emulation.
1202 if (IsWin11OrLater()) {
1203 mOscpu.AssignLiteral(OSCPU_WIN64);
1204 } else {
1205 mOscpu.AssignLiteral(OSCPU_WINDOWS);
1206 }
1207# else
1208 BOOL isWow64 = FALSE;
1209 if (!IsWow64Process(GetCurrentProcess(), &isWow64)) {
1210 isWow64 = FALSE;
1211 }
1212 if (isWow64) {
1213 mOscpu.AssignLiteral(OSCPU_WIN64);
1214 } else {
1215 mOscpu.AssignLiteral(OSCPU_WINDOWS);
1216 }
1217# endif
1218
1219#elif defined(XP_MACOSX)
1220 mOscpu.AssignLiteral("Intel Mac OS X 10.15");
1221#elif defined(ANDROID)
1222 mOscpu.AssignLiteral("Linux armv81");
1223#elif defined(XP_IOS)
1224 mOscpu.AssignLiteral("iPhone");
1225#else
1226 mOscpu.AssignLiteral("Linux x86_64");
1227#endif
1228
1229 mUserAgentIsDirty = true;
1230}
1231
1232#ifdef XP_MACOSX
1233void nsHttpHandler::InitMSAuthorities() {
1234 if (!StaticPrefs::network_http_microsoft_entra_sso_enabled()) {
1235 return;
1236 }
1237
1238 nsAutoCString authorityList;
1239
1240 if (NS_FAILED(Preferences::GetCString("network.microsoft-sso-authority-list",((bool)(__builtin_expect(!!(NS_FAILED_impl(Preferences::GetCString
("network.microsoft-sso-authority-list", authorityList))), 0)
))
1241 authorityList))((bool)(__builtin_expect(!!(NS_FAILED_impl(Preferences::GetCString
("network.microsoft-sso-authority-list", authorityList))), 0)
))
) {
1242 return;
1243 }
1244 mMSAuthorities.Clear();
1245
1246 // Normalize the MS authority list
1247 nsCCharSeparatedTokenizer tokenizer(authorityList, ',');
1248 while (tokenizer.hasMoreTokens()) {
1249 const nsDependentCSubstring& token = tokenizer.nextToken();
1250 mMSAuthorities.Insert(token);
1251 }
1252}
1253#endif
1254
1255uint32_t nsHttpHandler::MaxSocketCount() {
1256 PR_CallOnce(&nsSocketTransportService::gMaxCountInitOnce,
1257 nsSocketTransportService::DiscoverMaxCount);
1258 // Don't use the full max count because sockets can be held in
1259 // the persistent connection pool for a long time and that could
1260 // starve other users.
1261
1262 uint32_t maxCount = nsSocketTransportService::gMaxCount;
1263 if (maxCount <= 8) {
1264 maxCount = 1;
1265 } else {
1266 maxCount -= 8;
1267 }
1268
1269 return maxCount;
1270}
1271
1272// static
1273void nsHttpHandler::PrefsChanged(const char* pref, void* self) {
1274 static_cast<nsHttpHandler*>(self)->PrefsChanged(pref);
1275}
1276
1277void nsHttpHandler::PrefsChanged(const char* pref) {
1278 nsresult rv = NS_OK;
1279 int32_t val;
1280
1281 LOG(("nsHttpHandler::PrefsChanged [pref=%s]\n", pref))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged [pref=%s]\n"
, pref); } } while (0)
;
1282
1283 if (pref) {
1284 gIOService->NotifySocketProcessPrefsChanged(pref);
1285 }
1286
1287#define PREF_CHANGED(p) ((pref == nullptr) || !strcmp(pref, p))
1288#define MULTI_PREF_CHANGED(p) \
1289 ((pref == nullptr) || !strncmp(pref, p, sizeof(p) - 1))
1290
1291 // If a security pref changed, lets clear our connection pool reuse
1292 if (MULTI_PREF_CHANGED(SECURITY_PREFIX"security.")) {
1293 LOG(("nsHttpHandler::PrefsChanged Security Pref Changed %s\n", pref))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged Security Pref Changed %s\n"
, pref); } } while (0)
;
1294 if (mConnMgr) {
1295 rv = mConnMgr->DoShiftReloadConnectionCleanup();
1296 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
1297 LOG(do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"DoShiftReloadConnectionCleanup failed (%08x)\n", static_cast
<uint32_t>(rv)); } } while (0)
1298 ("nsHttpHandler::PrefsChanged "do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"DoShiftReloadConnectionCleanup failed (%08x)\n", static_cast
<uint32_t>(rv)); } } while (0)
1299 "DoShiftReloadConnectionCleanup failed (%08x)\n",do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"DoShiftReloadConnectionCleanup failed (%08x)\n", static_cast
<uint32_t>(rv)); } } while (0)
1300 static_cast<uint32_t>(rv)))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"DoShiftReloadConnectionCleanup failed (%08x)\n", static_cast
<uint32_t>(rv)); } } while (0)
;
1301 }
1302 rv = mConnMgr->PruneDeadConnections();
1303 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
1304 LOG(do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"PruneDeadConnections failed (%08x)\n", static_cast<uint32_t
>(rv)); } } while (0)
1305 ("nsHttpHandler::PrefsChanged "do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"PruneDeadConnections failed (%08x)\n", static_cast<uint32_t
>(rv)); } } while (0)
1306 "PruneDeadConnections failed (%08x)\n",do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"PruneDeadConnections failed (%08x)\n", static_cast<uint32_t
>(rv)); } } while (0)
1307 static_cast<uint32_t>(rv)))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"PruneDeadConnections failed (%08x)\n", static_cast<uint32_t
>(rv)); } } while (0)
;
1308 }
1309 }
1310 }
1311
1312 //
1313 // UA components
1314 //
1315
1316 bool cVar = false;
1317
1318 if (PREF_CHANGED(UA_PREF("compatMode.firefox")"general.useragent." "compatMode.firefox")) {
1319 rv = Preferences::GetBool(UA_PREF("compatMode.firefox")"general.useragent." "compatMode.firefox", &cVar);
1320 mCompatFirefoxEnabled = (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cVar);
1321 mUserAgentIsDirty = true;
1322 }
1323
1324 // general.useragent.override
1325 if (PREF_CHANGED(UA_PREF("override")"general.useragent." "override")) {
1326 Preferences::GetCString(UA_PREF("override")"general.useragent." "override", mUserAgentOverride);
1327 mUserAgentIsDirty = true;
1328 }
1329
1330#ifdef ANDROID
1331 // general.useragent.use_device
1332 if (PREF_CHANGED(UA_PREF("use_device")"general.useragent." "use_device")) {
1333 if (Preferences::GetBool(UA_PREF("use_device")"general.useragent." "use_device", false)) {
1334 if (!XRE_IsSocketProcess()) {
1335 mDeviceModelId = mozilla::net::GetDeviceModelId();
1336 if (gIOService->SocketProcessReady()) {
1337 RefPtr<SocketProcessParent> socketParent =
1338 SocketProcessParent::GetSingleton();
1339 (void)socketParent->SendUpdateDeviceModelId(mDeviceModelId);
1340 }
1341 }
1342 } else {
1343 mDeviceModelId.Truncate();
1344 }
1345 mUserAgentIsDirty = true;
1346 }
1347#endif
1348
1349 //
1350 // HTTP options
1351 //
1352
1353 if (PREF_CHANGED(HTTP_PREF("keep-alive.timeout")"network.http." "keep-alive.timeout")) {
1354 rv = Preferences::GetInt(HTTP_PREF("keep-alive.timeout")"network.http." "keep-alive.timeout", &val);
1355 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1356 mIdleTimeout = PR_SecondsToInterval(std::clamp(val, 1, 0xffff));
1357 }
1358 }
1359
1360 if (PREF_CHANGED(HTTP_PREF("request.max-attempts")"network.http." "request.max-attempts")) {
1361 rv = Preferences::GetInt(HTTP_PREF("request.max-attempts")"network.http." "request.max-attempts", &val);
1362 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1363 mMaxRequestAttempts = (uint16_t)std::clamp(val, 1, 0xffff);
1364 }
1365 }
1366
1367 if (PREF_CHANGED(HTTP_PREF("request.max-start-delay")"network.http." "request.max-start-delay")) {
1368 rv = Preferences::GetInt(HTTP_PREF("request.max-start-delay")"network.http." "request.max-start-delay", &val);
1369 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1370 mMaxRequestDelay = (uint16_t)std::clamp(val, 0, 0xffff);
1371 if (mConnMgr) {
1372 rv = mConnMgr->UpdateParam(nsHttpConnectionMgr::MAX_REQUEST_DELAY,
1373 mMaxRequestDelay);
1374 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
1375 LOG(do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged (request.max-start-delay)"
"UpdateParam failed (%08x)\n", static_cast<uint32_t>(rv
)); } } while (0)
1376 ("nsHttpHandler::PrefsChanged (request.max-start-delay)"do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged (request.max-start-delay)"
"UpdateParam failed (%08x)\n", static_cast<uint32_t>(rv
)); } } while (0)
1377 "UpdateParam failed (%08x)\n",do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged (request.max-start-delay)"
"UpdateParam failed (%08x)\n", static_cast<uint32_t>(rv
)); } } while (0)
1378 static_cast<uint32_t>(rv)))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged (request.max-start-delay)"
"UpdateParam failed (%08x)\n", static_cast<uint32_t>(rv
)); } } while (0)
;
1379 }
1380 }
1381 }
1382 }
1383
1384 if (PREF_CHANGED(HTTP_PREF("response.timeout")"network.http." "response.timeout")) {
1385 rv = Preferences::GetInt(HTTP_PREF("response.timeout")"network.http." "response.timeout", &val);
1386 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1387 mResponseTimeout = PR_SecondsToInterval(std::clamp(val, 0, 0xffff));
1388 }
1389 }
1390
1391 if (PREF_CHANGED(HTTP_PREF("network-changed.timeout")"network.http." "network-changed.timeout")) {
1392 rv = Preferences::GetInt(HTTP_PREF("network-changed.timeout")"network.http." "network-changed.timeout", &val);
1393 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1394 mNetworkChangedTimeout = std::clamp(val, 1, 600) * 1000;
1395 }
1396 }
1397
1398 if (PREF_CHANGED(HTTP_PREF("max-connections")"network.http." "max-connections")) {
1399 rv = Preferences::GetInt(HTTP_PREF("max-connections")"network.http." "max-connections", &val);
1400 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1401 mMaxConnections =
1402 (uint16_t)std::clamp((uint32_t)val, (uint32_t)1, MaxSocketCount());
1403
1404 if (mConnMgr) {
1405 rv = mConnMgr->UpdateParam(nsHttpConnectionMgr::MAX_CONNECTIONS,
1406 mMaxConnections);
1407 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
1408 LOG(do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged (max-connections)"
"UpdateParam failed (%08x)\n", static_cast<uint32_t>(rv
)); } } while (0)
1409 ("nsHttpHandler::PrefsChanged (max-connections)"do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged (max-connections)"
"UpdateParam failed (%08x)\n", static_cast<uint32_t>(rv
)); } } while (0)
1410 "UpdateParam failed (%08x)\n",do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged (max-connections)"
"UpdateParam failed (%08x)\n", static_cast<uint32_t>(rv
)); } } while (0)
1411 static_cast<uint32_t>(rv)))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged (max-connections)"
"UpdateParam failed (%08x)\n", static_cast<uint32_t>(rv
)); } } while (0)
;
1412 }
1413 }
1414 }
1415 }
1416
1417 if (PREF_CHANGED(
1418 HTTP_PREF("max-urgent-start-excessive-connections-per-host")"network.http." "max-urgent-start-excessive-connections-per-host")) {
1419 rv = Preferences::GetInt(
1420 HTTP_PREF("max-urgent-start-excessive-connections-per-host")"network.http." "max-urgent-start-excessive-connections-per-host", &val);
1421 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1422 mMaxUrgentExcessiveConns = (uint8_t)std::clamp(val, 1, 0xff);
1423 if (mConnMgr) {
1424 rv = mConnMgr->UpdateParam(nsHttpConnectionMgr::MAX_URGENT_START_Q,
1425 mMaxUrgentExcessiveConns);
1426 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
1427 LOG(do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"(max-urgent-start-excessive-connections-per-host)" "UpdateParam failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
1428 ("nsHttpHandler::PrefsChanged "do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"(max-urgent-start-excessive-connections-per-host)" "UpdateParam failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
1429 "(max-urgent-start-excessive-connections-per-host)"do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"(max-urgent-start-excessive-connections-per-host)" "UpdateParam failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
1430 "UpdateParam failed (%08x)\n",do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"(max-urgent-start-excessive-connections-per-host)" "UpdateParam failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
1431 static_cast<uint32_t>(rv)))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"(max-urgent-start-excessive-connections-per-host)" "UpdateParam failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
;
1432 }
1433 }
1434 }
1435 }
1436
1437 if (PREF_CHANGED(HTTP_PREF("max-persistent-connections-per-server")"network.http." "max-persistent-connections-per-server")) {
1438 rv = Preferences::GetInt(HTTP_PREF("max-persistent-connections-per-server")"network.http." "max-persistent-connections-per-server",
1439 &val);
1440 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1441 mMaxPersistentConnectionsPerServer = (uint8_t)std::clamp(val, 1, 0xff);
1442 if (mConnMgr) {
1443 rv = mConnMgr->UpdateParam(
1444 nsHttpConnectionMgr::MAX_PERSISTENT_CONNECTIONS_PER_HOST,
1445 mMaxPersistentConnectionsPerServer);
1446 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
1447 LOG(do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"(max-persistent-connections-per-server)" "UpdateParam failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
1448 ("nsHttpHandler::PrefsChanged "do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"(max-persistent-connections-per-server)" "UpdateParam failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
1449 "(max-persistent-connections-per-server)"do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"(max-persistent-connections-per-server)" "UpdateParam failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
1450 "UpdateParam failed (%08x)\n",do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"(max-persistent-connections-per-server)" "UpdateParam failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
1451 static_cast<uint32_t>(rv)))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"(max-persistent-connections-per-server)" "UpdateParam failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
;
1452 }
1453 }
1454 }
1455 }
1456
1457 if (PREF_CHANGED(HTTP_PREF("max-persistent-connections-per-proxy")"network.http." "max-persistent-connections-per-proxy")) {
1458 rv = Preferences::GetInt(HTTP_PREF("max-persistent-connections-per-proxy")"network.http." "max-persistent-connections-per-proxy",
1459 &val);
1460 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1461 mMaxPersistentConnectionsPerProxy = (uint8_t)std::clamp(val, 1, 0xff);
1462 if (mConnMgr) {
1463 rv = mConnMgr->UpdateParam(
1464 nsHttpConnectionMgr::MAX_PERSISTENT_CONNECTIONS_PER_PROXY,
1465 mMaxPersistentConnectionsPerProxy);
1466 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
1467 LOG(do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"(max-persistent-connections-per-proxy)" "UpdateParam failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
1468 ("nsHttpHandler::PrefsChanged "do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"(max-persistent-connections-per-proxy)" "UpdateParam failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
1469 "(max-persistent-connections-per-proxy)"do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"(max-persistent-connections-per-proxy)" "UpdateParam failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
1470 "UpdateParam failed (%08x)\n",do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"(max-persistent-connections-per-proxy)" "UpdateParam failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
1471 static_cast<uint32_t>(rv)))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::PrefsChanged "
"(max-persistent-connections-per-proxy)" "UpdateParam failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
;
1472 }
1473 }
1474 }
1475 }
1476
1477 if (PREF_CHANGED(HTTP_PREF("redirection-limit")"network.http." "redirection-limit")) {
1478 rv = Preferences::GetInt(HTTP_PREF("redirection-limit")"network.http." "redirection-limit", &val);
1479 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) mRedirectionLimit = (uint8_t)std::clamp(val, 0, 0xff);
1480 }
1481
1482 if (PREF_CHANGED(HTTP_PREF("connection-retry-timeout")"network.http." "connection-retry-timeout")) {
1483 rv = Preferences::GetInt(HTTP_PREF("connection-retry-timeout")"network.http." "connection-retry-timeout", &val);
1484 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) mIdleSynTimeout = (uint16_t)std::clamp(val, 0, 3000);
1485 }
1486
1487 if (PREF_CHANGED(HTTP_PREF("fast-fallback-to-IPv4")"network.http." "fast-fallback-to-IPv4")) {
1488 rv = Preferences::GetBool(HTTP_PREF("fast-fallback-to-IPv4")"network.http." "fast-fallback-to-IPv4", &cVar);
1489 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) mFastFallbackToIPv4 = cVar;
1490 }
1491
1492 if (PREF_CHANGED(HTTP_PREF("fallback-connection-timeout")"network.http." "fallback-connection-timeout")) {
1493 rv = Preferences::GetInt(HTTP_PREF("fallback-connection-timeout")"network.http." "fallback-connection-timeout", &val);
1494 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1495 mFallbackSynTimeout = (uint16_t)std::clamp(val, 0, 10 * 60);
1496 }
1497 }
1498
1499 if (PREF_CHANGED(HTTP_PREF("version")"network.http." "version")) {
1500 nsAutoCString httpVersion;
1501 Preferences::GetCString(HTTP_PREF("version")"network.http." "version", httpVersion);
1502 if (!httpVersion.IsVoid()) {
1503 if (httpVersion.EqualsLiteral("1.1")) {
1504 mHttpVersion = HttpVersion::v1_1;
1505 } else if (httpVersion.EqualsLiteral("0.9")) {
1506 mHttpVersion = HttpVersion::v0_9;
1507 } else {
1508 mHttpVersion = HttpVersion::v1_0;
1509 }
1510 }
1511 }
1512
1513 if (PREF_CHANGED(HTTP_PREF("proxy.version")"network.http." "proxy.version")) {
1514 nsAutoCString httpVersion;
1515 Preferences::GetCString(HTTP_PREF("proxy.version")"network.http." "proxy.version", httpVersion);
1516 if (!httpVersion.IsVoid()) {
1517 if (httpVersion.EqualsLiteral("1.1")) {
1518 mProxyHttpVersion = HttpVersion::v1_1;
1519 } else {
1520 mProxyHttpVersion = HttpVersion::v1_0;
1521 }
1522 // it does not make sense to issue a HTTP/0.9 request to a proxy server
1523 }
1524 }
1525
1526 if (PREF_CHANGED(HTTP_PREF("proxy.respect-be-conservative")"network.http." "proxy.respect-be-conservative")) {
1527 rv =
1528 Preferences::GetBool(HTTP_PREF("proxy.respect-be-conservative")"network.http." "proxy.respect-be-conservative", &cVar);
1529 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1530 mBeConservativeForProxy = cVar;
1531 if (mConnMgr) {
1532 (void)mConnMgr->UpdateParam(
1533 nsHttpConnectionMgr::PROXY_BE_CONSERVATIVE,
1534 static_cast<int32_t>(mBeConservativeForProxy));
1535 }
1536 }
1537 }
1538
1539 if (PREF_CHANGED(HTTP_PREF("qos")"network.http." "qos")) {
1540 rv = Preferences::GetInt(HTTP_PREF("qos")"network.http." "qos", &val);
1541 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) mQoSBits = (uint8_t)std::clamp(val, 0, 0xff);
1542 }
1543
1544 if (PREF_CHANGED(HTTP_PREF("accept-encoding")"network.http." "accept-encoding")) {
1545 nsAutoCString acceptEncodings;
1546 rv = Preferences::GetCString(HTTP_PREF("accept-encoding")"network.http." "accept-encoding", acceptEncodings);
1547 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1548 rv = SetAcceptEncodings(acceptEncodings.get(), false, false);
1549 MOZ_ASSERT(NS_SUCCEEDED(rv))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)
)))>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)
))))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 1549); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))"
")"); do { MOZ_CrashSequence(__null, 1549); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1550 }
1551 }
1552
1553 if (PREF_CHANGED(HTTP_PREF("accept-encoding.secure")"network.http." "accept-encoding.secure") ||
1554 PREF_CHANGED(HTTP_PREF("accept-encoding.dictionary")"network.http." "accept-encoding.dictionary")) {
1555 nsAutoCString acceptEncodings;
1556 rv = Preferences::GetCString(HTTP_PREF("accept-encoding.secure")"network.http." "accept-encoding.secure",
1557 acceptEncodings);
1558 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1559 rv = SetAcceptEncodings(acceptEncodings.get(), true, false);
1560
1561 // Since dictionary encodings are dependent on both accept-encoding.secure
1562 // and accept-encoding.dictionary, update both if either changes (which is
1563 // quite rare, so there's no real perf hit)
1564 nsAutoCString acceptDictionaryEncodings;
1565 nsresult rvDic = Preferences::GetCString(
1566 HTTP_PREF("accept-encoding.dictionary")"network.http." "accept-encoding.dictionary", acceptDictionaryEncodings);
1567 if (NS_SUCCEEDED(rvDic)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rvDic)), 1))) && !acceptDictionaryEncodings.IsEmpty()) {
1568 acceptEncodings.Append(", "_ns);
1569 acceptEncodings.Append(acceptDictionaryEncodings);
1570 rv = SetAcceptEncodings(acceptEncodings.get(), true, true);
1571 }
1572 MOZ_ASSERT(NS_SUCCEEDED(rv))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)
)))>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)
))))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 1572); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))"
")"); do { MOZ_CrashSequence(__null, 1572); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1573 }
1574 }
1575
1576 if (PREF_CHANGED(HTTP_PREF("default-socket-type")"network.http." "default-socket-type")) {
1577 nsAutoCString sval;
1578 rv = Preferences::GetCString(HTTP_PREF("default-socket-type")"network.http." "default-socket-type", sval);
1579 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1580 if (sval.IsEmpty()) {
1581 mDefaultSocketType.SetIsVoid(true);
1582 } else {
1583 // verify that this socket type is actually valid
1584 nsCOMPtr<nsISocketProviderService> sps =
1585 nsSocketProviderService::GetOrCreate();
1586 if (sps) {
1587 nsCOMPtr<nsISocketProvider> sp;
1588 rv = sps->GetSocketProvider(sval.get(), getter_AddRefs(sp));
1589 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1590 // OK, this looks like a valid socket provider.
1591 mDefaultSocketType.Assign(sval);
1592 }
1593 }
1594 }
1595 }
1596 }
1597
1598 if (PREF_CHANGED(HTTP_PREF("prompt-temp-redirect")"network.http." "prompt-temp-redirect")) {
1599 rv = Preferences::GetBool(HTTP_PREF("prompt-temp-redirect")"network.http." "prompt-temp-redirect", &cVar);
1600 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1601 mPromptTempRedirect = cVar;
1602 }
1603 }
1604
1605 if (PREF_CHANGED(HTTP_PREF("assoc-req.enforce")"network.http." "assoc-req.enforce")) {
1606 cVar = false;
1607 rv = Preferences::GetBool(HTTP_PREF("assoc-req.enforce")"network.http." "assoc-req.enforce", &cVar);
1608 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) mEnforceAssocReq = cVar;
1609 }
1610
1611 // enable Persistent caching for HTTPS - bug#205921
1612 if (PREF_CHANGED(BROWSER_PREF("disk_cache_ssl")"browser.cache." "disk_cache_ssl")) {
1613 cVar = false;
1614 rv = Preferences::GetBool(BROWSER_PREF("disk_cache_ssl")"browser.cache." "disk_cache_ssl", &cVar);
1615 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) mEnablePersistentHttpsCaching = cVar;
1616 }
1617
1618 if (PREF_CHANGED(HTTP_PREF("http2.timeout")"network.http." "http2.timeout")) {
1619 mSpdyTimeout = PR_SecondsToInterval(
1620 std::clamp(StaticPrefs::network_http_http2_timeout(), 1, 0xffff));
1621 }
1622
1623 if (PREF_CHANGED(HTTP_PREF("http2.chunk-size")"network.http." "http2.chunk-size")) {
1624 // keep this within http/2 ranges of 1 to 2^24-1
1625 mSpdySendingChunkSize = (uint32_t)std::clamp(
1626 StaticPrefs::network_http_http2_chunk_size(), 1, 0xffffff);
1627 }
1628
1629 // The amount of idle seconds on a http2 connection before initiating a
1630 // server ping. 0 will disable.
1631 if (PREF_CHANGED(HTTP_PREF("http2.ping-threshold")"network.http." "http2.ping-threshold")) {
1632 mSpdyPingThreshold = PR_SecondsToInterval((uint16_t)std::clamp(
1633 StaticPrefs::network_http_http2_ping_threshold(), 0, 0x7fffffff));
1634 }
1635
1636 // The amount of seconds to wait for a http2 ping response before
1637 // closing the session.
1638 if (PREF_CHANGED(HTTP_PREF("http2.ping-timeout")"network.http." "http2.ping-timeout")) {
1639 mSpdyPingTimeout = PR_SecondsToInterval((uint16_t)std::clamp(
1640 StaticPrefs::network_http_http2_ping_timeout(), 0, 0x7fffffff));
1641 }
1642
1643 if (PREF_CHANGED(HTTP_PREF("altsvc.enabled")"network.http." "altsvc.enabled")) {
1644 rv = Preferences::GetBool(HTTP_PREF("altsvc.enabled")"network.http." "altsvc.enabled", &cVar);
1645 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) mEnableAltSvc = cVar;
1646 }
1647
1648 if (PREF_CHANGED(HTTP_PREF("http2.push-allowance")"network.http." "http2.push-allowance")) {
1649 mSpdyPushAllowance = static_cast<uint32_t>(
1650 std::clamp(StaticPrefs::network_http_http2_push_allowance(), 1024,
1651 static_cast<int32_t>(ASpdySession::kInitialRwin)));
1652 }
1653
1654 if (PREF_CHANGED(HTTP_PREF("http2.pull-allowance")"network.http." "http2.pull-allowance")) {
1655 mSpdyPullAllowance = static_cast<uint32_t>(std::clamp(
1656 StaticPrefs::network_http_http2_pull_allowance(), 1024, 0x7fffffff));
1657 }
1658
1659 if (PREF_CHANGED(HTTP_PREF("http2.default-concurrent")"network.http." "http2.default-concurrent")) {
1660 mDefaultSpdyConcurrent = static_cast<uint32_t>(std::max<int32_t>(
1661 std::min<int32_t>(StaticPrefs::network_http_http2_default_concurrent(),
1662 9999),
1663 1));
1664 }
1665
1666 // If http2.send-buffer-size is non-zero, the size to set the TCP
1667 // sendbuffer to once the stream has surpassed this number of bytes uploaded
1668 if (PREF_CHANGED(HTTP_PREF("http2.send-buffer-size")"network.http." "http2.send-buffer-size")) {
1669 mSpdySendBufferSize = (uint32_t)std::clamp(
1670 StaticPrefs::network_http_http2_send_buffer_size(), 1500, 0x7fffffff);
1671 }
1672
1673 // The maximum amount of time to wait for socket transport to be
1674 // established
1675 if (PREF_CHANGED(HTTP_PREF("connection-timeout")"network.http." "connection-timeout")) {
1676 rv = Preferences::GetInt(HTTP_PREF("connection-timeout")"network.http." "connection-timeout", &val);
1677 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1678 // the pref is in seconds, but the variable is in milliseconds
1679 mConnectTimeout = std::clamp(val, 1, 0xffff) * PR_MSEC_PER_SEC1000L;
1680 }
1681 }
1682
1683 // The maximum amount of time to wait for a tls handshake to finish.
1684 if (PREF_CHANGED(HTTP_PREF("tls-handshake-timeout")"network.http." "tls-handshake-timeout")) {
1685 rv = Preferences::GetInt(HTTP_PREF("tls-handshake-timeout")"network.http." "tls-handshake-timeout", &val);
1686 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1687 // the pref is in seconds, but the variable is in milliseconds
1688 mTLSHandshakeTimeout = std::clamp(val, 1, 0xffff) * PR_MSEC_PER_SEC1000L;
1689 }
1690 }
1691
1692 // The maximum number of current global half open sockets allowable
1693 // for starting a new speculative connection.
1694 if (PREF_CHANGED(HTTP_PREF("speculative-parallel-limit")"network.http." "speculative-parallel-limit")) {
1695 rv = Preferences::GetInt(HTTP_PREF("speculative-parallel-limit")"network.http." "speculative-parallel-limit", &val);
1696 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1697 mParallelSpeculativeConnectLimit = (uint32_t)std::clamp(val, 0, 1024);
1698 }
1699 }
1700
1701 // Whether or not to block requests for non head js/css items (e.g. media)
1702 // while those elements load.
1703 if (PREF_CHANGED(HTTP_PREF("rendering-critical-requests-prioritization")"network.http." "rendering-critical-requests-prioritization")) {
1704 rv = Preferences::GetBool(
1705 HTTP_PREF("rendering-critical-requests-prioritization")"network.http." "rendering-critical-requests-prioritization", &cVar);
1706 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) mCriticalRequestPrioritization = cVar;
1707 }
1708
1709 // on transition of network.http.diagnostics to true print
1710 // a bunch of information to the console
1711 if (pref && PREF_CHANGED(HTTP_PREF("diagnostics")"network.http." "diagnostics")) {
1712 rv = Preferences::GetBool(HTTP_PREF("diagnostics")"network.http." "diagnostics", &cVar);
1713 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cVar) {
1714 if (mConnMgr) mConnMgr->PrintDiagnostics();
1715 }
1716 }
1717
1718 if (PREF_CHANGED(HTTP_PREF("throttle.enable")"network.http." "throttle.enable")) {
1719 rv = Preferences::GetBool(HTTP_PREF("throttle.enable")"network.http." "throttle.enable", &mThrottleEnabled);
1720 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && mConnMgr) {
1721 (void)mConnMgr->UpdateParam(nsHttpConnectionMgr::THROTTLING_ENABLED,
1722 static_cast<int32_t>(mThrottleEnabled));
1723 }
1724 }
1725
1726 if (PREF_CHANGED(HTTP_PREF("throttle.suspend-for")"network.http." "throttle.suspend-for")) {
1727 rv = Preferences::GetInt(HTTP_PREF("throttle.suspend-for")"network.http." "throttle.suspend-for", &val);
1728 mThrottleSuspendFor = (uint32_t)std::clamp(val, 0, 120000);
1729 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && mConnMgr) {
1730 (void)mConnMgr->UpdateParam(nsHttpConnectionMgr::THROTTLING_SUSPEND_FOR,
1731 mThrottleSuspendFor);
1732 }
1733 }
1734
1735 if (PREF_CHANGED(HTTP_PREF("throttle.resume-for")"network.http." "throttle.resume-for")) {
1736 rv = Preferences::GetInt(HTTP_PREF("throttle.resume-for")"network.http." "throttle.resume-for", &val);
1737 mThrottleResumeFor = (uint32_t)std::clamp(val, 0, 120000);
1738 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && mConnMgr) {
1739 (void)mConnMgr->UpdateParam(nsHttpConnectionMgr::THROTTLING_RESUME_FOR,
1740 mThrottleResumeFor);
1741 }
1742 }
1743
1744 if (PREF_CHANGED(HTTP_PREF("throttle.hold-time-ms")"network.http." "throttle.hold-time-ms")) {
1745 rv = Preferences::GetInt(HTTP_PREF("throttle.hold-time-ms")"network.http." "throttle.hold-time-ms", &val);
1746 mThrottleHoldTime = (uint32_t)std::clamp(val, 0, 120000);
1747 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && mConnMgr) {
1748 (void)mConnMgr->UpdateParam(nsHttpConnectionMgr::THROTTLING_HOLD_TIME,
1749 mThrottleHoldTime);
1750 }
1751 }
1752
1753 if (PREF_CHANGED(HTTP_PREF("throttle.max-time-ms")"network.http." "throttle.max-time-ms")) {
1754 rv = Preferences::GetInt(HTTP_PREF("throttle.max-time-ms")"network.http." "throttle.max-time-ms", &val);
1755 mThrottleMaxTime = (uint32_t)std::clamp(val, 0, 120000);
1756 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && mConnMgr) {
1757 (void)mConnMgr->UpdateParam(nsHttpConnectionMgr::THROTTLING_MAX_TIME,
1758 mThrottleMaxTime);
1759 }
1760 }
1761
1762 if (PREF_CHANGED(HTTP_PREF("send_window_size")"network.http." "send_window_size")) {
1763 (void)Preferences::GetInt(HTTP_PREF("send_window_size")"network.http." "send_window_size", &val);
1764 mSendWindowSize = val >= 0 ? val : 0;
1765 }
1766
1767 if (PREF_CHANGED(HTTP_PREF("on_click_priority")"network.http." "on_click_priority")) {
1768 (void)Preferences::GetBool(HTTP_PREF("on_click_priority")"network.http." "on_click_priority",
1769 &mUrgentStartEnabled);
1770 }
1771
1772 if (PREF_CHANGED(HTTP_PREF("tailing.enabled")"network.http." "tailing.enabled")) {
1773 (void)Preferences::GetBool(HTTP_PREF("tailing.enabled")"network.http." "tailing.enabled",
1774 &mTailBlockingEnabled);
1775 }
1776 if (PREF_CHANGED(HTTP_PREF("tailing.delay-quantum")"network.http." "tailing.delay-quantum")) {
1777 val = StaticPrefs::network_http_tailing_delay_quantum();
1778 mTailDelayQuantum = (uint32_t)std::clamp(val, 0, 60000);
1779 }
1780 if (PREF_CHANGED(HTTP_PREF("tailing.delay-quantum-after-domcontentloaded")"network.http." "tailing.delay-quantum-after-domcontentloaded")) {
1781 val = StaticPrefs::
1782 network_http_tailing_delay_quantum_after_domcontentloaded();
1783 mTailDelayQuantumAfterDCL = (uint32_t)std::clamp(val, 0, 60000);
1784 }
1785 if (PREF_CHANGED(HTTP_PREF("tailing.delay-max")"network.http." "tailing.delay-max")) {
1786 val = StaticPrefs::network_http_tailing_delay_max();
1787 mTailDelayMax = (uint32_t)std::clamp(val, 0, 60000);
1788 }
1789 if (PREF_CHANGED(HTTP_PREF("tailing.total-max")"network.http." "tailing.total-max")) {
1790 val = StaticPrefs::network_http_tailing_total_max();
1791 mTailTotalMax = (uint32_t)std::clamp(val, 0, 60000);
1792 }
1793
1794 if (PREF_CHANGED(HTTP_PREF("focused_window_transaction_ratio")"network.http." "focused_window_transaction_ratio")) {
1795 float ratio = 0;
1796 rv = Preferences::GetFloat(HTTP_PREF("focused_window_transaction_ratio")"network.http." "focused_window_transaction_ratio",
1797 &ratio);
1798 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1799 if (ratio > 0 && ratio < 1) {
1800 auto lockedRatio = mFocusedWindowTransactionRatio.Lock();
1801 *lockedRatio = ratio;
1802 } else {
1803 NS_WARNING("Wrong value for focused_window_transaction_ratio")NS_DebugBreak(NS_DEBUG_WARNING, "Wrong value for focused_window_transaction_ratio"
, nullptr, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 1803)
;
1804 }
1805 }
1806 }
1807
1808 //
1809 // INTL options
1810 //
1811
1812 if (PREF_CHANGED(INTL_ACCEPT_LANGUAGES"intl.accept_languages")) {
1813 // We don't want to set the new accept languages here since
1814 // this pref is a complex type and it may be racy with flushing
1815 // string resources.
1816 mAcceptLanguagesIsDirty = true;
1817 }
1818
1819 //
1820 // Tracking options
1821 //
1822
1823 // Hint option
1824 if (PREF_CHANGED(SAFE_HINT_HEADER_VALUE"safeHint.enabled")) {
1825 cVar = false;
1826 rv = Preferences::GetBool(SAFE_HINT_HEADER_VALUE"safeHint.enabled", &cVar);
1827 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1828 mSafeHintEnabled = cVar;
1829 }
1830 }
1831
1832 // toggle to true anytime a token bucket related pref is changed.. that
1833 // includes telemetry and allow-experiments because of the abtest profile
1834 bool requestTokenBucketUpdated = false;
1835
1836 // "security.ssl3.ecdhe_rsa_aes_128_gcm_sha256" is the required h2 interop
1837 // suite.
1838
1839 if (PREF_CHANGED(H2MANDATORY_SUITE"security.ssl3.ecdhe_rsa_aes_128_gcm_sha256")) {
1840 cVar = false;
1841 rv = Preferences::GetBool(H2MANDATORY_SUITE"security.ssl3.ecdhe_rsa_aes_128_gcm_sha256", &cVar);
1842 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1843 mH2MandatorySuiteEnabled = cVar;
1844 }
1845 }
1846
1847 // network.http.debug-observations
1848 if (PREF_CHANGED("network.http.debug-observations")) {
1849 cVar = false;
1850 rv = Preferences::GetBool("network.http.debug-observations", &cVar);
1851 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1852 mDebugObservations = cVar;
1853 }
1854 }
1855
1856 if (PREF_CHANGED(HTTP_PREF("pacing.requests.enabled")"network.http." "pacing.requests.enabled")) {
1857 rv = Preferences::GetBool(HTTP_PREF("pacing.requests.enabled")"network.http." "pacing.requests.enabled", &cVar);
1858 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1859 mRequestTokenBucketEnabled = cVar;
1860 requestTokenBucketUpdated = true;
1861 }
1862 }
1863 if (PREF_CHANGED(HTTP_PREF("pacing.requests.min-parallelism")"network.http." "pacing.requests.min-parallelism")) {
1864 rv =
1865 Preferences::GetInt(HTTP_PREF("pacing.requests.min-parallelism")"network.http." "pacing.requests.min-parallelism", &val);
1866 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1867 mRequestTokenBucketMinParallelism =
1868 static_cast<uint16_t>(std::clamp(val, 1, 1024));
1869 requestTokenBucketUpdated = true;
1870 }
1871 }
1872 if (PREF_CHANGED(HTTP_PREF("pacing.requests.hz")"network.http." "pacing.requests.hz")) {
1873 rv = Preferences::GetInt(HTTP_PREF("pacing.requests.hz")"network.http." "pacing.requests.hz", &val);
1874 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1875 mRequestTokenBucketHz = static_cast<uint32_t>(std::clamp(val, 1, 10000));
1876 requestTokenBucketUpdated = true;
1877 }
1878 }
1879 if (PREF_CHANGED(HTTP_PREF("pacing.requests.burst")"network.http." "pacing.requests.burst")) {
1880 rv = Preferences::GetInt(HTTP_PREF("pacing.requests.burst")"network.http." "pacing.requests.burst", &val);
1881 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1882 mRequestTokenBucketBurst = val ? val : 1;
1883 requestTokenBucketUpdated = true;
1884 }
1885 }
1886 if (requestTokenBucketUpdated) {
1887 MakeNewRequestTokenBucket();
1888 }
1889
1890 // Keepalive values for initial and idle connections.
1891 if (PREF_CHANGED(HTTP_PREF("tcp_keepalive.short_lived_connections")"network.http." "tcp_keepalive.short_lived_connections")) {
1892 rv = Preferences::GetBool(
1893 HTTP_PREF("tcp_keepalive.short_lived_connections")"network.http." "tcp_keepalive.short_lived_connections", &cVar);
1894 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cVar != mTCPKeepaliveShortLivedEnabled) {
1895 mTCPKeepaliveShortLivedEnabled = cVar;
1896 }
1897 }
1898
1899 if (PREF_CHANGED(HTTP_PREF("tcp_keepalive.short_lived_time")"network.http." "tcp_keepalive.short_lived_time")) {
1900 rv = Preferences::GetInt(HTTP_PREF("tcp_keepalive.short_lived_time")"network.http." "tcp_keepalive.short_lived_time", &val);
1901 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && val > 0) {
1902 mTCPKeepaliveShortLivedTimeS = std::clamp(val, 1, 300); // Max 5 mins.
1903 }
1904 }
1905
1906 if (PREF_CHANGED(HTTP_PREF("tcp_keepalive.short_lived_idle_time")"network.http." "tcp_keepalive.short_lived_idle_time")) {
1907 rv = Preferences::GetInt(HTTP_PREF("tcp_keepalive.short_lived_idle_time")"network.http." "tcp_keepalive.short_lived_idle_time",
1908 &val);
1909 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && val > 0) {
1910 mTCPKeepaliveShortLivedIdleTimeS = std::clamp(val, 1, kMaxTCPKeepIdle);
1911 }
1912 }
1913
1914 // Keepalive values for Long-lived Connections.
1915 if (PREF_CHANGED(HTTP_PREF("tcp_keepalive.long_lived_connections")"network.http." "tcp_keepalive.long_lived_connections")) {
1916 rv = Preferences::GetBool(HTTP_PREF("tcp_keepalive.long_lived_connections")"network.http." "tcp_keepalive.long_lived_connections",
1917 &cVar);
1918 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cVar != mTCPKeepaliveLongLivedEnabled) {
1919 mTCPKeepaliveLongLivedEnabled = cVar;
1920 }
1921 }
1922
1923 if (PREF_CHANGED(HTTP_PREF("tcp_keepalive.long_lived_idle_time")"network.http." "tcp_keepalive.long_lived_idle_time")) {
1924 rv = Preferences::GetInt(HTTP_PREF("tcp_keepalive.long_lived_idle_time")"network.http." "tcp_keepalive.long_lived_idle_time",
1925 &val);
1926 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && val > 0) {
1927 mTCPKeepaliveLongLivedIdleTimeS = std::clamp(val, 1, kMaxTCPKeepIdle);
1928 }
1929 }
1930
1931 if (PREF_CHANGED(HTTP_PREF("enforce-framing.http1")"network.http." "enforce-framing.http1") ||
1932 PREF_CHANGED(HTTP_PREF("enforce-framing.soft")"network.http." "enforce-framing.soft") ||
1933 PREF_CHANGED(HTTP_PREF("enforce-framing.strict_chunked_encoding")"network.http." "enforce-framing.strict_chunked_encoding")) {
1934 rv = Preferences::GetBool(HTTP_PREF("enforce-framing.http1")"network.http." "enforce-framing.http1", &cVar);
1935 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cVar) {
1936 mEnforceH1Framing = FRAMECHECK_STRICT;
1937 } else {
1938 rv = Preferences::GetBool(
1939 HTTP_PREF("enforce-framing.strict_chunked_encoding")"network.http." "enforce-framing.strict_chunked_encoding", &cVar);
1940 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cVar) {
1941 mEnforceH1Framing = FRAMECHECK_STRICT_CHUNKED;
1942 } else {
1943 rv = Preferences::GetBool(HTTP_PREF("enforce-framing.soft")"network.http." "enforce-framing.soft", &cVar);
1944 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cVar) {
1945 mEnforceH1Framing = FRAMECHECK_BARELY;
1946 } else {
1947 mEnforceH1Framing = FRAMECHECK_LAX;
1948 }
1949 }
1950 }
1951 }
1952
1953 if (PREF_CHANGED(HTTP_PREF("http2.default-hpack-buffer")"network.http." "http2.default-hpack-buffer")) {
1954 mDefaultHpackBuffer =
1955 StaticPrefs::network_http_http2_default_hpack_buffer();
1956 }
1957
1958 if (PREF_CHANGED(HTTP_PREF("http3.default-qpack-table-size")"network.http." "http3.default-qpack-table-size")) {
1959 rv = Preferences::GetInt(HTTP_PREF("http3.default-qpack-table-size")"network.http." "http3.default-qpack-table-size", &val);
1960 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1961 mQpackTableSize = val;
1962 }
1963 }
1964
1965 if (PREF_CHANGED(HTTP_PREF("http3.default-max-stream-blocked")"network.http." "http3.default-max-stream-blocked")) {
1966 rv = Preferences::GetInt(HTTP_PREF("http3.default-max-stream-blocked")"network.http." "http3.default-max-stream-blocked",
1967 &val);
1968 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
1969 mHttp3MaxBlockedStreams = std::clamp(val, 0, 0xffff);
1970 }
1971 }
1972
1973 const bool imageAcceptPrefChanged =
1974 PREF_CHANGED("image.http.accept") || PREF_CHANGED("image.jxl.enabled");
1975
1976 if (imageAcceptPrefChanged) {
1977 nsAutoCString userSetImageAcceptHeader;
1978
1979 if (Preferences::HasUserValue("image.http.accept")) {
1980 rv = Preferences::GetCString("image.http.accept",
1981 userSetImageAcceptHeader);
1982 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
1983 userSetImageAcceptHeader.Truncate();
1984 }
1985 }
1986
1987 if (userSetImageAcceptHeader.IsEmpty()) {
1988 mImageAcceptHeader.Assign(ImageAcceptHeader());
1989 } else {
1990 mImageAcceptHeader.Assign(userSetImageAcceptHeader);
1991 }
1992 }
1993
1994 if (PREF_CHANGED("network.http.accept") || imageAcceptPrefChanged) {
1995 nsAutoCString userSetDocumentAcceptHeader;
1996
1997 if (Preferences::HasUserValue("network.http.accept")) {
1998 rv = Preferences::GetCString("network.http.accept",
1999 userSetDocumentAcceptHeader);
2000 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
2001 userSetDocumentAcceptHeader.Truncate();
2002 }
2003 }
2004
2005 if (userSetDocumentAcceptHeader.IsEmpty()) {
2006 mDocumentAcceptHeader.Assign(DocumentAcceptHeader());
2007 } else {
2008 mDocumentAcceptHeader.Assign(userSetDocumentAcceptHeader);
2009 }
2010 }
2011
2012 if (PREF_CHANGED(HTTP_PREF("http3.alt-svc-mapping-for-testing")"network.http." "http3.alt-svc-mapping-for-testing")) {
2013 nsAutoCString altSvcMappings;
2014 rv = Preferences::GetCString(HTTP_PREF("http3.alt-svc-mapping-for-testing")"network.http." "http3.alt-svc-mapping-for-testing",
2015 altSvcMappings);
2016 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
2017 auto map = mAltSvcMappingTemptativeMap.Lock();
2018 if (altSvcMappings.IsEmpty()) {
2019 map->Clear();
2020 } else {
2021 for (const nsACString& tokenSubstring :
2022 nsCCharSeparatedTokenizer(altSvcMappings, ',').ToRange()) {
2023 nsAutoCString token{tokenSubstring};
2024 int32_t index = token.Find(";");
2025 if (index != kNotFound) {
2026 map->InsertOrUpdate(
2027 Substring(token, 0, index),
2028 MakeUnique<nsCString>(Substring(token, index + 1)));
2029 }
2030 }
2031 }
2032 }
2033 }
2034
2035 if (PREF_CHANGED(HTTP_PREF("http3.enable_qlog")"network.http." "http3.enable_qlog")) {
2036 // Initialize the directory.
2037 nsCOMPtr<nsIFile> qlogDir;
2038 if (Preferences::GetBool(HTTP_PREF("http3.enable_qlog")"network.http." "http3.enable_qlog") &&
2039 !mHttp3QlogDir.IsEmpty() &&
2040 NS_SUCCEEDED(((bool)(__builtin_expect(!!(!NS_FAILED_impl(NS_NewNativeLocalFile
(mHttp3QlogDir, getter_AddRefs(qlogDir)))), 1)))
2041 NS_NewNativeLocalFile(mHttp3QlogDir, getter_AddRefs(qlogDir)))((bool)(__builtin_expect(!!(!NS_FAILED_impl(NS_NewNativeLocalFile
(mHttp3QlogDir, getter_AddRefs(qlogDir)))), 1)))
) {
2042 // Here we do main thread IO, but since this only happens
2043 // when enabling a developer feature it's not a problem for users.
2044 rv = qlogDir->Create(nsIFile::DIRECTORY_TYPE, 0755);
2045 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0))) && rv != NS_ERROR_FILE_ALREADY_EXISTS) {
2046 NS_WARNING("Creating qlog dir failed")NS_DebugBreak(NS_DEBUG_WARNING, "Creating qlog dir failed", nullptr
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2046)
;
2047 }
2048 }
2049 }
2050
2051#ifdef XP_MACOSX
2052 if (XRE_IsParentProcess()) {
2053 if (PREF_CHANGED(HTTP_PREF("microsoft-entra-sso.enabled")"network.http." "microsoft-entra-sso.enabled")) {
2054 rv =
2055 Preferences::GetBool(HTTP_PREF("microsoft-entra-sso.enabled")"network.http." "microsoft-entra-sso.enabled", &cVar);
2056 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cVar) {
2057 InitMSAuthorities();
2058 }
2059 }
2060 }
2061#endif
2062
2063 // Enable HTTP response timeout if TCP Keepalives are disabled.
2064 mResponseTimeoutEnabled =
2065 !mTCPKeepaliveShortLivedEnabled && !mTCPKeepaliveLongLivedEnabled;
2066
2067#undef PREF_CHANGED
2068#undef MULTI_PREF_CHANGED
2069}
2070
2071/**
2072 * Allocates a C string into that contains a ISO 639 language list
2073 * notated with HTTP "q" values for output with a HTTP Accept-Language
2074 * header. Previous q values will be stripped because the order of
2075 * the langs imply the q value. The q values are calculated by dividing
2076 * 1.0 amongst the number of languages present.
2077 *
2078 * Ex: passing: "en, ja"
2079 * returns: "en,ja;q=0.5"
2080 *
2081 * passing: "en, ja, fr_CA"
2082 * returns: "en,ja;q=0.7,fr_CA;q=0.3"
2083 */
2084static nsresult PrepareAcceptLanguages(const char* i_AcceptLanguages,
2085 nsACString& o_AcceptLanguages) {
2086 if (!i_AcceptLanguages) return NS_OK;
2087
2088 const nsAutoCString ns_accept_languages(i_AcceptLanguages);
2089 return rust_prepare_accept_languages(&ns_accept_languages,
2090 &o_AcceptLanguages);
2091}
2092
2093// Ensure that we've fetched the AcceptLanguages setting
2094/* static */
2095void nsHttpHandler::PresetAcceptLanguages() {
2096 if (!gHttpHandler) {
2097 RefPtr<nsHttpHandler> handler = nsHttpHandler::GetInstance();
2098 (void)handler.get();
2099 }
2100 [[maybe_unused]] nsresult rv = gHttpHandler->SetAcceptLanguages();
2101}
2102
2103nsresult nsHttpHandler::SetAcceptLanguages() {
2104 if (!NS_IsMainThread()) {
2105 nsCOMPtr<nsIThread> mainThread;
2106 nsresult rv = NS_GetMainThread(getter_AddRefs(mainThread));
2107 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
2108 return rv;
2109 }
2110
2111 // Forward to the main thread synchronously.
2112 SyncRunnable::DispatchToThread(
2113 mainThread,
2114 NS_NewRunnableFunction("nsHttpHandler::SetAcceptLanguages", [&rv]() {
2115 rv = gHttpHandler->SetAcceptLanguages();
2116 }));
2117 return rv;
2118 }
2119
2120 MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(NS_IsMainThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2120); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()"
")"); do { MOZ_CrashSequence(__null, 2120); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2121
2122 mAcceptLanguagesIsDirty = false;
2123
2124 nsAutoCString acceptLanguages;
2125 intl::LocaleService::GetInstance()->GetAcceptLanguages(acceptLanguages);
2126
2127 nsAutoCString buf;
2128 nsresult rv = PrepareAcceptLanguages(acceptLanguages.get(), buf);
2129 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
2130 mAcceptLanguages.Assign(buf);
2131 }
2132 return rv;
2133}
2134
2135nsresult nsHttpHandler::SetAcceptEncodings(const char* aAcceptEncodings,
2136 bool isSecure, bool isDictionary) {
2137 if (isDictionary) {
2138 mDictionaryAcceptEncodings = aAcceptEncodings;
2139 } else if (isSecure) {
2140 mHttpsAcceptEncodings = aAcceptEncodings;
2141 } else {
2142 // use legacy list if a secure override is not specified
2143 mHttpAcceptEncodings = aAcceptEncodings;
2144 if (mHttpsAcceptEncodings.IsEmpty()) {
2145 mHttpsAcceptEncodings = aAcceptEncodings;
2146 }
2147 }
2148
2149 return NS_OK;
2150}
2151
2152//-----------------------------------------------------------------------------
2153// nsHttpHandler::nsISupports
2154//-----------------------------------------------------------------------------
2155
2156NS_IMPL_ISUPPORTS(nsHttpHandler, nsIHttpProtocolHandler,MozExternalRefCountType nsHttpHandler::AddRef(void) { static_assert
(!std::is_destructible_v<nsHttpHandler>, "Reference-counted class "
"nsHttpHandler" " should not have a public destructor. " "Make this class's destructor non-public"
); do { static_assert( mozilla::detail::AssertionConditionType
<decltype(int32_t(mRefCnt) >= 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(int32_t(mRefCnt) >= 0))),
0))) { do { } while (false); MOZ_ReportAssertionFailure("int32_t(mRefCnt) >= 0"
" (" "illegal refcnt" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2158); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0"
") (" "illegal refcnt" ")"); do { MOZ_CrashSequence(__null, 2158
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); do { static_assert( mozilla::detail::AssertionConditionType
<decltype("nsHttpHandler" != nullptr)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!("nsHttpHandler" != nullptr))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("\"nsHttpHandler\" != nullptr"
" (" "Must specify a name" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2158); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpHandler\" != nullptr"
") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null
, 2158); __attribute__((nomerge)) ::abort(); } while (false);
} } while (false); if (!mRefCnt.isThreadSafe) _mOwningThread
.AssertOwnership("nsHttpHandler" " not thread-safe"); nsrefcnt
count = ++mRefCnt; NS_LogAddRef((this), (count), ("nsHttpHandler"
), (uint32_t)(sizeof(*this))); return count; } MozExternalRefCountType
nsHttpHandler::Release(void) { do { static_assert( mozilla::
detail::AssertionConditionType<decltype(int32_t(mRefCnt) >
0)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(int32_t(mRefCnt) > 0))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("int32_t(mRefCnt) > 0" " (" "dup release"
")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2158); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0"
") (" "dup release" ")"); do { MOZ_CrashSequence(__null, 2158
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); do { static_assert( mozilla::detail::AssertionConditionType
<decltype("nsHttpHandler" != nullptr)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!("nsHttpHandler" != nullptr))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("\"nsHttpHandler\" != nullptr"
" (" "Must specify a name" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2158); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpHandler\" != nullptr"
") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null
, 2158); __attribute__((nomerge)) ::abort(); } while (false);
} } while (false); if (!mRefCnt.isThreadSafe) _mOwningThread
.AssertOwnership("nsHttpHandler" " not thread-safe"); const char
* const nametmp = "nsHttpHandler"; nsrefcnt count = --mRefCnt
; NS_LogRelease((this), (count), (nametmp)); if (count == 0) {
mRefCnt = 1; delete (this); return 0; } return count; } nsresult
nsHttpHandler::QueryInterface(const nsIID& aIID, void** aInstancePtr
) { do { if (!(aInstancePtr)) { NS_DebugBreak(NS_DEBUG_ASSERTION
, "QueryInterface requires a non-NULL destination!", "aInstancePtr"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2158); MOZ_PretendNoReturn(); } } while (0); nsresult rv = NS_ERROR_FAILURE
; static_assert(6 > 0, "Need more arguments to NS_INTERFACE_TABLE"
); static const QITableEntry table[] = { {&mozilla::detail
::kImplementedIID<nsHttpHandler, nsIHttpProtocolHandler>
, int32_t( reinterpret_cast<char*>(static_cast<nsIHttpProtocolHandler
*>((nsHttpHandler*)0x1000)) - reinterpret_cast<char*>
((nsHttpHandler*)0x1000))}, {&mozilla::detail::kImplementedIID
<nsHttpHandler, nsIProxiedProtocolHandler>, int32_t( reinterpret_cast
<char*>(static_cast<nsIProxiedProtocolHandler*>((
nsHttpHandler*)0x1000)) - reinterpret_cast<char*>((nsHttpHandler
*)0x1000))}, {&mozilla::detail::kImplementedIID<nsHttpHandler
, nsIProtocolHandler>, int32_t( reinterpret_cast<char*>
(static_cast<nsIProtocolHandler*>((nsHttpHandler*)0x1000
)) - reinterpret_cast<char*>((nsHttpHandler*)0x1000))},
{&mozilla::detail::kImplementedIID<nsHttpHandler, nsIObserver
>, int32_t( reinterpret_cast<char*>(static_cast<nsIObserver
*>((nsHttpHandler*)0x1000)) - reinterpret_cast<char*>
((nsHttpHandler*)0x1000))}, {&mozilla::detail::kImplementedIID
<nsHttpHandler, nsISupportsWeakReference>, int32_t( reinterpret_cast
<char*>(static_cast<nsISupportsWeakReference*>((nsHttpHandler
*)0x1000)) - reinterpret_cast<char*>((nsHttpHandler*)0x1000
))}, {&mozilla::detail::kImplementedIID<nsHttpHandler,
nsISpeculativeConnect>, int32_t( reinterpret_cast<char
*>(static_cast<nsISpeculativeConnect*>((nsHttpHandler
*)0x1000)) - reinterpret_cast<char*>((nsHttpHandler*)0x1000
))}, {&mozilla::detail::kImplementedIID<nsHttpHandler,
nsISupports>, int32_t(reinterpret_cast<char*>(static_cast
<nsISupports*>( static_cast<nsIHttpProtocolHandler*>
((nsHttpHandler*)0x1000))) - reinterpret_cast<char*>((nsHttpHandler
*)0x1000))}, { nullptr, 0 } } ; static_assert(std::size(table
) > 1, "need at least 1 interface"); rv = NS_TableDrivenQI
(static_cast<void*>(this), aIID, aInstancePtr, table); return
rv; }
2157 nsIProxiedProtocolHandler, nsIProtocolHandler, nsIObserver,MozExternalRefCountType nsHttpHandler::AddRef(void) { static_assert
(!std::is_destructible_v<nsHttpHandler>, "Reference-counted class "
"nsHttpHandler" " should not have a public destructor. " "Make this class's destructor non-public"
); do { static_assert( mozilla::detail::AssertionConditionType
<decltype(int32_t(mRefCnt) >= 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(int32_t(mRefCnt) >= 0))),
0))) { do { } while (false); MOZ_ReportAssertionFailure("int32_t(mRefCnt) >= 0"
" (" "illegal refcnt" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2158); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0"
") (" "illegal refcnt" ")"); do { MOZ_CrashSequence(__null, 2158
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); do { static_assert( mozilla::detail::AssertionConditionType
<decltype("nsHttpHandler" != nullptr)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!("nsHttpHandler" != nullptr))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("\"nsHttpHandler\" != nullptr"
" (" "Must specify a name" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2158); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpHandler\" != nullptr"
") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null
, 2158); __attribute__((nomerge)) ::abort(); } while (false);
} } while (false); if (!mRefCnt.isThreadSafe) _mOwningThread
.AssertOwnership("nsHttpHandler" " not thread-safe"); nsrefcnt
count = ++mRefCnt; NS_LogAddRef((this), (count), ("nsHttpHandler"
), (uint32_t)(sizeof(*this))); return count; } MozExternalRefCountType
nsHttpHandler::Release(void) { do { static_assert( mozilla::
detail::AssertionConditionType<decltype(int32_t(mRefCnt) >
0)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(int32_t(mRefCnt) > 0))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("int32_t(mRefCnt) > 0" " (" "dup release"
")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2158); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0"
") (" "dup release" ")"); do { MOZ_CrashSequence(__null, 2158
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); do { static_assert( mozilla::detail::AssertionConditionType
<decltype("nsHttpHandler" != nullptr)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!("nsHttpHandler" != nullptr))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("\"nsHttpHandler\" != nullptr"
" (" "Must specify a name" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2158); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpHandler\" != nullptr"
") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null
, 2158); __attribute__((nomerge)) ::abort(); } while (false);
} } while (false); if (!mRefCnt.isThreadSafe) _mOwningThread
.AssertOwnership("nsHttpHandler" " not thread-safe"); const char
* const nametmp = "nsHttpHandler"; nsrefcnt count = --mRefCnt
; NS_LogRelease((this), (count), (nametmp)); if (count == 0) {
mRefCnt = 1; delete (this); return 0; } return count; } nsresult
nsHttpHandler::QueryInterface(const nsIID& aIID, void** aInstancePtr
) { do { if (!(aInstancePtr)) { NS_DebugBreak(NS_DEBUG_ASSERTION
, "QueryInterface requires a non-NULL destination!", "aInstancePtr"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2158); MOZ_PretendNoReturn(); } } while (0); nsresult rv = NS_ERROR_FAILURE
; static_assert(6 > 0, "Need more arguments to NS_INTERFACE_TABLE"
); static const QITableEntry table[] = { {&mozilla::detail
::kImplementedIID<nsHttpHandler, nsIHttpProtocolHandler>
, int32_t( reinterpret_cast<char*>(static_cast<nsIHttpProtocolHandler
*>((nsHttpHandler*)0x1000)) - reinterpret_cast<char*>
((nsHttpHandler*)0x1000))}, {&mozilla::detail::kImplementedIID
<nsHttpHandler, nsIProxiedProtocolHandler>, int32_t( reinterpret_cast
<char*>(static_cast<nsIProxiedProtocolHandler*>((
nsHttpHandler*)0x1000)) - reinterpret_cast<char*>((nsHttpHandler
*)0x1000))}, {&mozilla::detail::kImplementedIID<nsHttpHandler
, nsIProtocolHandler>, int32_t( reinterpret_cast<char*>
(static_cast<nsIProtocolHandler*>((nsHttpHandler*)0x1000
)) - reinterpret_cast<char*>((nsHttpHandler*)0x1000))},
{&mozilla::detail::kImplementedIID<nsHttpHandler, nsIObserver
>, int32_t( reinterpret_cast<char*>(static_cast<nsIObserver
*>((nsHttpHandler*)0x1000)) - reinterpret_cast<char*>
((nsHttpHandler*)0x1000))}, {&mozilla::detail::kImplementedIID
<nsHttpHandler, nsISupportsWeakReference>, int32_t( reinterpret_cast
<char*>(static_cast<nsISupportsWeakReference*>((nsHttpHandler
*)0x1000)) - reinterpret_cast<char*>((nsHttpHandler*)0x1000
))}, {&mozilla::detail::kImplementedIID<nsHttpHandler,
nsISpeculativeConnect>, int32_t( reinterpret_cast<char
*>(static_cast<nsISpeculativeConnect*>((nsHttpHandler
*)0x1000)) - reinterpret_cast<char*>((nsHttpHandler*)0x1000
))}, {&mozilla::detail::kImplementedIID<nsHttpHandler,
nsISupports>, int32_t(reinterpret_cast<char*>(static_cast
<nsISupports*>( static_cast<nsIHttpProtocolHandler*>
((nsHttpHandler*)0x1000))) - reinterpret_cast<char*>((nsHttpHandler
*)0x1000))}, { nullptr, 0 } } ; static_assert(std::size(table
) > 1, "need at least 1 interface"); rv = NS_TableDrivenQI
(static_cast<void*>(this), aIID, aInstancePtr, table); return
rv; }
2158 nsISupportsWeakReference, nsISpeculativeConnect)MozExternalRefCountType nsHttpHandler::AddRef(void) { static_assert
(!std::is_destructible_v<nsHttpHandler>, "Reference-counted class "
"nsHttpHandler" " should not have a public destructor. " "Make this class's destructor non-public"
); do { static_assert( mozilla::detail::AssertionConditionType
<decltype(int32_t(mRefCnt) >= 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(int32_t(mRefCnt) >= 0))),
0))) { do { } while (false); MOZ_ReportAssertionFailure("int32_t(mRefCnt) >= 0"
" (" "illegal refcnt" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2158); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0"
") (" "illegal refcnt" ")"); do { MOZ_CrashSequence(__null, 2158
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); do { static_assert( mozilla::detail::AssertionConditionType
<decltype("nsHttpHandler" != nullptr)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!("nsHttpHandler" != nullptr))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("\"nsHttpHandler\" != nullptr"
" (" "Must specify a name" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2158); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpHandler\" != nullptr"
") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null
, 2158); __attribute__((nomerge)) ::abort(); } while (false);
} } while (false); if (!mRefCnt.isThreadSafe) _mOwningThread
.AssertOwnership("nsHttpHandler" " not thread-safe"); nsrefcnt
count = ++mRefCnt; NS_LogAddRef((this), (count), ("nsHttpHandler"
), (uint32_t)(sizeof(*this))); return count; } MozExternalRefCountType
nsHttpHandler::Release(void) { do { static_assert( mozilla::
detail::AssertionConditionType<decltype(int32_t(mRefCnt) >
0)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(int32_t(mRefCnt) > 0))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("int32_t(mRefCnt) > 0" " (" "dup release"
")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2158); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0"
") (" "dup release" ")"); do { MOZ_CrashSequence(__null, 2158
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); do { static_assert( mozilla::detail::AssertionConditionType
<decltype("nsHttpHandler" != nullptr)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!("nsHttpHandler" != nullptr))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("\"nsHttpHandler\" != nullptr"
" (" "Must specify a name" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2158); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpHandler\" != nullptr"
") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null
, 2158); __attribute__((nomerge)) ::abort(); } while (false);
} } while (false); if (!mRefCnt.isThreadSafe) _mOwningThread
.AssertOwnership("nsHttpHandler" " not thread-safe"); const char
* const nametmp = "nsHttpHandler"; nsrefcnt count = --mRefCnt
; NS_LogRelease((this), (count), (nametmp)); if (count == 0) {
mRefCnt = 1; delete (this); return 0; } return count; } nsresult
nsHttpHandler::QueryInterface(const nsIID& aIID, void** aInstancePtr
) { do { if (!(aInstancePtr)) { NS_DebugBreak(NS_DEBUG_ASSERTION
, "QueryInterface requires a non-NULL destination!", "aInstancePtr"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2158); MOZ_PretendNoReturn(); } } while (0); nsresult rv = NS_ERROR_FAILURE
; static_assert(6 > 0, "Need more arguments to NS_INTERFACE_TABLE"
); static const QITableEntry table[] = { {&mozilla::detail
::kImplementedIID<nsHttpHandler, nsIHttpProtocolHandler>
, int32_t( reinterpret_cast<char*>(static_cast<nsIHttpProtocolHandler
*>((nsHttpHandler*)0x1000)) - reinterpret_cast<char*>
((nsHttpHandler*)0x1000))}, {&mozilla::detail::kImplementedIID
<nsHttpHandler, nsIProxiedProtocolHandler>, int32_t( reinterpret_cast
<char*>(static_cast<nsIProxiedProtocolHandler*>((
nsHttpHandler*)0x1000)) - reinterpret_cast<char*>((nsHttpHandler
*)0x1000))}, {&mozilla::detail::kImplementedIID<nsHttpHandler
, nsIProtocolHandler>, int32_t( reinterpret_cast<char*>
(static_cast<nsIProtocolHandler*>((nsHttpHandler*)0x1000
)) - reinterpret_cast<char*>((nsHttpHandler*)0x1000))},
{&mozilla::detail::kImplementedIID<nsHttpHandler, nsIObserver
>, int32_t( reinterpret_cast<char*>(static_cast<nsIObserver
*>((nsHttpHandler*)0x1000)) - reinterpret_cast<char*>
((nsHttpHandler*)0x1000))}, {&mozilla::detail::kImplementedIID
<nsHttpHandler, nsISupportsWeakReference>, int32_t( reinterpret_cast
<char*>(static_cast<nsISupportsWeakReference*>((nsHttpHandler
*)0x1000)) - reinterpret_cast<char*>((nsHttpHandler*)0x1000
))}, {&mozilla::detail::kImplementedIID<nsHttpHandler,
nsISpeculativeConnect>, int32_t( reinterpret_cast<char
*>(static_cast<nsISpeculativeConnect*>((nsHttpHandler
*)0x1000)) - reinterpret_cast<char*>((nsHttpHandler*)0x1000
))}, {&mozilla::detail::kImplementedIID<nsHttpHandler,
nsISupports>, int32_t(reinterpret_cast<char*>(static_cast
<nsISupports*>( static_cast<nsIHttpProtocolHandler*>
((nsHttpHandler*)0x1000))) - reinterpret_cast<char*>((nsHttpHandler
*)0x1000))}, { nullptr, 0 } } ; static_assert(std::size(table
) > 1, "need at least 1 interface"); rv = NS_TableDrivenQI
(static_cast<void*>(this), aIID, aInstancePtr, table); return
rv; }
2159
2160//-----------------------------------------------------------------------------
2161// nsHttpHandler::nsIProtocolHandler
2162//-----------------------------------------------------------------------------
2163
2164NS_IMETHODIMPnsresult
2165nsHttpHandler::GetScheme(nsACString& aScheme) {
2166 aScheme.AssignLiteral("http");
2167 return NS_OK;
2168}
2169
2170NS_IMETHODIMPnsresult
2171nsHttpHandler::NewChannel(nsIURI* uri, nsILoadInfo* aLoadInfo,
2172 nsIChannel** result) {
2173 LOG(("nsHttpHandler::NewChannel\n"))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::NewChannel\n"
); } } while (0)
;
2174
2175 NS_ENSURE_ARG_POINTER(uri)do { if ((__builtin_expect(!!(!(uri)), 0))) { NS_DebugBreak(NS_DEBUG_WARNING
, "NS_ENSURE_TRUE(" "uri" ") failed", nullptr, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2175); return NS_ERROR_INVALID_POINTER; } } while (false)
;
2176 NS_ENSURE_ARG_POINTER(result)do { if ((__builtin_expect(!!(!(result)), 0))) { NS_DebugBreak
(NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "result" ") failed", nullptr
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2176); return NS_ERROR_INVALID_POINTER; } } while (false)
;
2177
2178 // Verify that we have been given a valid scheme
2179 if (!net::SchemeIsHttpOrHttps(uri)) {
2180 NS_WARNING("Invalid URI scheme")NS_DebugBreak(NS_DEBUG_WARNING, "Invalid URI scheme", nullptr
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2180)
;
2181 return NS_ERROR_UNEXPECTED;
2182 }
2183
2184 return NewProxiedChannel(uri, nullptr, 0, nullptr, aLoadInfo, result);
2185}
2186
2187NS_IMETHODIMPnsresult
2188nsHttpHandler::AllowPort(int32_t port, const char* scheme, bool* _retval) {
2189 // don't override anything.
2190 *_retval = false;
2191 return NS_OK;
2192}
2193
2194//-----------------------------------------------------------------------------
2195// nsHttpHandler::nsIProxiedProtocolHandler
2196//-----------------------------------------------------------------------------
2197
2198nsresult nsHttpHandler::SetupChannelInternal(
2199 HttpBaseChannel* aChannel, nsIURI* uri, nsIProxyInfo* givenProxyInfo,
2200 uint32_t proxyResolveFlags, nsIURI* proxyURI, nsILoadInfo* aLoadInfo,
2201 nsIChannel** result) {
2202 RefPtr<HttpBaseChannel> httpChannel = aChannel;
2203
2204 nsCOMPtr<nsProxyInfo> proxyInfo;
2205 if (givenProxyInfo) {
2206 proxyInfo = do_QueryInterface(givenProxyInfo);
2207 NS_ENSURE_ARG(proxyInfo)do { if ((__builtin_expect(!!(!(proxyInfo)), 0))) { NS_DebugBreak
(NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "proxyInfo" ") failed", nullptr
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2207); return NS_ERROR_INVALID_ARG; } } while (false)
;
2208 }
2209
2210 uint32_t caps = mCapabilities;
2211
2212 uint64_t channelId = NewChannelId();
2213 nsresult rv = httpChannel->Init(uri, caps, proxyInfo, proxyResolveFlags,
2214 proxyURI, channelId, aLoadInfo);
2215 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv;
2216
2217 httpChannel.forget(result);
2218 return NS_OK;
2219}
2220
2221NS_IMETHODIMPnsresult
2222nsHttpHandler::NewProxiedChannel(nsIURI* uri, nsIProxyInfo* givenProxyInfo,
2223 uint32_t proxyResolveFlags, nsIURI* proxyURI,
2224 nsILoadInfo* aLoadInfo, nsIChannel** result) {
2225 HttpBaseChannel* httpChannel;
2226
2227 LOG(("nsHttpHandler::NewProxiedChannel [proxyInfo=%p]\n", givenProxyInfo))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::NewProxiedChannel [proxyInfo=%p]\n"
, givenProxyInfo); } } while (0)
;
2228
2229 if (IsNeckoChild()) {
2230 httpChannel = new HttpChannelChild();
2231 } else {
2232 // HACK: make sure PSM gets initialized on the main thread.
2233 net_EnsurePSMInit();
2234 httpChannel = new nsHttpChannel();
2235 }
2236
2237 return SetupChannelInternal(httpChannel, uri, givenProxyInfo,
2238 proxyResolveFlags, proxyURI, aLoadInfo, result);
2239}
2240
2241nsresult nsHttpHandler::CreateTRRServiceChannel(
2242 nsIURI* uri, nsIProxyInfo* givenProxyInfo, uint32_t proxyResolveFlags,
2243 nsIURI* proxyURI, nsILoadInfo* aLoadInfo, nsIChannel** result) {
2244 HttpBaseChannel* httpChannel = new TRRServiceChannel();
2245
2246 LOG(("nsHttpHandler::CreateTRRServiceChannel [proxyInfo=%p]\n",do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::CreateTRRServiceChannel [proxyInfo=%p]\n"
, givenProxyInfo); } } while (0)
2247 givenProxyInfo))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::CreateTRRServiceChannel [proxyInfo=%p]\n"
, givenProxyInfo); } } while (0)
;
2248
2249 return SetupChannelInternal(httpChannel, uri, givenProxyInfo,
2250 proxyResolveFlags, proxyURI, aLoadInfo, result);
2251}
2252
2253//-----------------------------------------------------------------------------
2254// nsHttpHandler::nsIHttpProtocolHandler
2255//-----------------------------------------------------------------------------
2256
2257NS_IMETHODIMPnsresult
2258nsHttpHandler::GetUserAgent(nsACString& value) {
2259 value = UserAgent(false);
2260 return NS_OK;
2261}
2262
2263NS_IMETHODIMPnsresult
2264nsHttpHandler::GetRfpUserAgent(nsACString& value) {
2265 value = UserAgent(true);
2266 return NS_OK;
2267}
2268
2269NS_IMETHODIMPnsresult
2270nsHttpHandler::GetDocumentAcceptHeader(nsACString& value) {
2271 value = mDocumentAcceptHeader;
2272 return NS_OK;
2273}
2274
2275NS_IMETHODIMPnsresult
2276nsHttpHandler::GetAppName(nsACString& value) {
2277 value = mLegacyAppName;
2278 return NS_OK;
2279}
2280
2281NS_IMETHODIMPnsresult
2282nsHttpHandler::GetAppVersion(nsACString& value) {
2283 value = mLegacyAppVersion;
2284 return NS_OK;
2285}
2286
2287NS_IMETHODIMPnsresult
2288nsHttpHandler::GetPlatform(nsACString& value) {
2289 value = mPlatform;
2290 return NS_OK;
2291}
2292
2293NS_IMETHODIMPnsresult
2294nsHttpHandler::GetOscpu(nsACString& value) {
2295 value = mOscpu;
2296 return NS_OK;
2297}
2298
2299NS_IMETHODIMPnsresult
2300nsHttpHandler::GetMisc(nsACString& value) {
2301 value = mMisc;
2302 return NS_OK;
2303}
2304
2305NS_IMETHODIMPnsresult
2306nsHttpHandler::GetAltSvcCacheKeys(nsTArray<nsCString>& value) {
2307 return mAltSvcCache->GetAltSvcCacheKeys(value);
2308}
2309
2310NS_IMETHODIMPnsresult
2311nsHttpHandler::GetAuthCacheKeys(nsTArray<nsCString>& aValues) {
2312 mAuthCache->CollectKeys(aValues);
2313 mPrivateAuthCache->CollectKeys(aValues);
2314 return NS_OK;
2315}
2316
2317//-----------------------------------------------------------------------------
2318// nsHttpHandler::nsIObserver
2319//-----------------------------------------------------------------------------
2320
2321NS_IMETHODIMPnsresult
2322nsHttpHandler::Observe(nsISupports* subject, const char* topic,
2323 const char16_t* data) {
2324 MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(NS_IsMainThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2324); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()"
")"); do { MOZ_CrashSequence(__null, 2324); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2325 LOG(("nsHttpHandler::Observe [topic=\"%s\"]\n", topic))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::Observe [topic=\"%s\"]\n"
, topic); } } while (0)
;
2326
2327 nsresult rv;
2328 if (!strcmp(topic, "profile-change-net-teardown") ||
2329 !strcmp(topic, NS_XPCOM_SHUTDOWN_OBSERVER_ID"xpcom-shutdown")) {
2330 mHandlerActive = false;
2331
2332 // clear cache of all authentication credentials.
2333 mAuthCache->ClearAll();
2334 mPrivateAuthCache->ClearAll();
2335 if (mWifiTickler) mWifiTickler->Cancel();
2336
2337 // Inform nsIOService that network is tearing down.
2338 gIOService->SetHttpHandlerAlreadyShutingDown();
2339
2340 ShutdownConnectionManager();
2341
2342 // need to reset the session start time since cache validation may
2343 // depend on this value.
2344 mSessionStartTime = NowInSeconds()PRTimeToSeconds(PR_Now());
2345
2346 // Since nsHttpHandler::Observe() is also called in socket process, we don't
2347 // want to do telemetry twice.
2348 if (XRE_IsParentProcess()) {
2349 if (!StaticPrefs::privacy_donottrackheader_enabled()) {
2350 glean::http::dnt_usage.AccumulateSingleSample(2);
2351 } else {
2352 glean::http::dnt_usage.AccumulateSingleSample(1);
2353 }
2354 }
2355
2356 mActivityDistributor = nullptr;
2357 } else if (!strcmp(topic, "net:clear-active-logins")) {
2358 mAuthCache->ClearAll();
2359 mPrivateAuthCache->ClearAll();
2360 } else if (!strcmp(topic, "net:cancel-all-connections")) {
2361 if (mConnMgr) {
2362 mConnMgr->AbortAndCloseAllConnections(0, nullptr);
2363 }
2364 } else if (!strcmp(topic, "net:prune-dead-connections")) {
2365 if (mConnMgr) {
2366 rv = mConnMgr->PruneDeadConnections();
2367 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
2368 LOG((" PruneDeadConnections failed (%08x)\n",do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, " PruneDeadConnections failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
2369 static_cast<uint32_t>(rv)))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, " PruneDeadConnections failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
;
2370 }
2371 }
2372 } else if (!strcmp(topic, "net:prune-all-connections")) {
2373 if (mConnMgr) {
2374 rv = mConnMgr->DoShiftReloadConnectionCleanup();
2375 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
2376 LOG((" DoShiftReloadConnectionCleanup failed (%08x)\n",do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, " DoShiftReloadConnectionCleanup failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
2377 static_cast<uint32_t>(rv)))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, " DoShiftReloadConnectionCleanup failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
;
2378 }
2379 rv = mConnMgr->PruneDeadConnections();
2380 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
2381 LOG((" PruneDeadConnections failed (%08x)\n",do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, " PruneDeadConnections failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
2382 static_cast<uint32_t>(rv)))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, " PruneDeadConnections failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
;
2383 }
2384 }
2385#if 0
2386 } else if (!strcmp(topic, "net:failed-to-process-uri-content")) {
2387 // nop right now - we used to cancel h1 pipelines based on this,
2388 // but those are no longer implemented
2389 nsCOMPtr<nsIURI> uri = do_QueryInterface(subject);
2390#endif
2391 } else if (!strcmp(topic, "last-pb-context-exited")) {
2392 mPrivateAuthCache->ClearAll();
2393 if (mAltSvcCache) {
2394 mAltSvcCache->ClearAltServiceMappings();
2395 }
2396 nsCORSListenerProxy::ClearPrivateBrowsingCache();
2397 } else if (!strcmp(topic, "browser:purge-session-history")) {
2398 if (mConnMgr) {
2399 (void)mConnMgr->ClearConnectionHistory();
2400 }
2401 if (mAltSvcCache) {
2402 mAltSvcCache->ClearAltServiceMappings();
2403 }
2404 } else if (!strcmp(topic, NS_NETWORK_LINK_TOPIC"network:link-status-changed")) {
2405 if (mConnMgr) {
2406 rv = mConnMgr->PruneDeadConnections();
2407 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
2408 LOG((" PruneDeadConnections failed (%08x)\n",do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, " PruneDeadConnections failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
2409 static_cast<uint32_t>(rv)))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, " PruneDeadConnections failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
;
2410 }
2411 rv = mConnMgr->VerifyTraffic();
2412 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
2413 LOG((" VerifyTraffic failed (%08x)\n", static_cast<uint32_t>(rv)))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, " VerifyTraffic failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
;
2414 }
2415 // We exclude HTTP/3 for an origin when any error occurs during
2416 // connection establishment. A common error is caused by UDP being blocked
2417 // by the network. When the network changes, it’s likely that UDP is no
2418 // longer blocked, so we should reset the exclusion list to give HTTP/3
2419 // another chance.
2420 MutexAutoLock lock(mHttpExclusionLock);
2421 mExcludedHttp3Origins.Clear();
2422 }
2423 } else if (!strcmp(topic, "application-background")) {
2424 // going to the background on android means we should close
2425 // down idle connections for power conservation
2426 if (mConnMgr) {
2427 rv = mConnMgr->DoShiftReloadConnectionCleanup();
2428 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
2429 LOG((" DoShiftReloadConnectionCleanup failed (%08x)\n",do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, " DoShiftReloadConnectionCleanup failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
2430 static_cast<uint32_t>(rv)))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, " DoShiftReloadConnectionCleanup failed (%08x)\n"
, static_cast<uint32_t>(rv)); } } while (0)
;
2431 }
2432 }
2433 } else if (!strcmp(topic, "net:current-browser-id")) {
2434 // The window id will be updated by HttpConnectionMgrParent.
2435 if (XRE_IsParentProcess()) {
2436 nsCOMPtr<nsISupportsPRUint64> wrapper = do_QueryInterface(subject);
2437 MOZ_RELEASE_ASSERT(wrapper)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(wrapper)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(wrapper))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("wrapper", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2437); AnnotateMozCrashReason("MOZ_RELEASE_ASSERT" "(" "wrapper"
")"); do { MOZ_CrashSequence(__null, 2437); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2438
2439 uint64_t id = 0;
2440 wrapper->GetData(&id);
2441 MOZ_ASSERT(id)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(id)>::isValid, "invalid assertion condition"); if
((__builtin_expect(!!(!(!!(id))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("id", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2441); AnnotateMozCrashReason("MOZ_ASSERT" "(" "id" ")"); do
{ MOZ_CrashSequence(__null, 2441); __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
;
2442
2443 static uint64_t sCurrentBrowserId = 0;
2444 if (sCurrentBrowserId != id) {
2445 sCurrentBrowserId = id;
2446 if (mConnMgr) {
2447 mConnMgr->UpdateCurrentBrowserId(sCurrentBrowserId);
2448 }
2449 }
2450 }
2451 } else if (!strcmp(topic, "intl:app-locales-changed")) {
2452 // If the locale changed, there's a chance the accept language did too
2453 mAcceptLanguagesIsDirty = true;
2454 } else if (!strcmp(topic, "network:reset-http3-excluded-list")) {
2455 MutexAutoLock lock(mHttpExclusionLock);
2456 mExcludedHttp3Origins.Clear();
2457 } else if (!strcmp(topic, "network:socket-process-crashed")) {
2458 ShutdownConnectionManager();
2459 mConnMgr = nullptr;
2460 (void)InitConnectionMgr();
2461 } else if (!strcmp(topic, "idle-daily")) {
2462 // Submit the local-network-access ping once per day
2463 if (XRE_IsParentProcess()) {
2464 glean_pings::LocalNetworkAccess.Submit();
2465 }
2466 }
2467 return NS_OK;
2468}
2469
2470// nsISpeculativeConnect
2471
2472nsresult nsHttpHandler::SpeculativeConnectInternal(
2473 nsIURI* aURI, nsIPrincipal* aPrincipal,
2474 Maybe<OriginAttributes>&& aOriginAttributes,
2475 nsIInterfaceRequestor* aCallbacks, bool anonymous) {
2476 if (IsNeckoChild()) {
2477 nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(aCallbacks);
2478
2479 gNeckoChild->SendSpeculativeConnect(
2480 nullptr, IPC::SerializedLoadContext(loadContext), aURI, aPrincipal,
2481 std::move(aOriginAttributes), anonymous);
2482 return NS_OK;
2483 }
2484
2485 if (!mHandlerActive) return NS_OK;
2486
2487 MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(NS_IsMainThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2487); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()"
")"); do { MOZ_CrashSequence(__null, 2487); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2488
2489 nsISiteSecurityService* sss = gHttpHandler->GetSSService();
2490 bool isStsHost = false;
2491 if (!sss) return NS_OK;
2492
2493 nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(aCallbacks);
2494 OriginAttributes originAttributes;
2495 // If the principal is given, we use the originAttributes from this
2496 // principal. Otherwise, we use the originAttributes from the loadContext.
2497 if (aOriginAttributes) {
2498 originAttributes = std::move(aOriginAttributes.ref());
2499 } else if (aPrincipal) {
2500 originAttributes = aPrincipal->OriginAttributesRef();
2501 } else if (loadContext) {
2502 loadContext->GetOriginAttributes(originAttributes);
2503 }
2504
2505 nsCOMPtr<nsIURI> clone;
2506 if (NS_SUCCEEDED(sss->IsSecureURI(aURI, originAttributes, &isStsHost))((bool)(__builtin_expect(!!(!NS_FAILED_impl(sss->IsSecureURI
(aURI, originAttributes, &isStsHost))), 1)))
&&
2507 isStsHost) {
2508 if (NS_SUCCEEDED(NS_GetSecureUpgradedURI(aURI, getter_AddRefs(clone)))((bool)(__builtin_expect(!!(!NS_FAILED_impl(NS_GetSecureUpgradedURI
(aURI, getter_AddRefs(clone)))), 1)))
) {
2509 aURI = clone.get();
2510 // (NOTE: We better make sure |clone| stays alive until the end
2511 // of the function now, since our aURI arg now points to it!)
2512 }
2513 }
2514
2515 if (!aOriginAttributes) {
2516 // We must update the originAttributes with the network state first party
2517 // domain **after** we upgrade aURI to https.
2518 // Otherwise the speculative connection will be keyed by a http URL
2519 // and end up not being used.
2520 StoragePrincipalHelper::UpdateOriginAttributesForNetworkState(
2521 aURI, originAttributes);
2522 }
2523
2524 nsAutoCString scheme;
2525 nsresult rv = aURI->GetScheme(scheme);
2526 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv;
2527
2528 // If this is HTTPS, make sure PSM is initialized as the channel
2529 // creation path may have been bypassed
2530 if (scheme.EqualsLiteral("https")) {
2531 if (!IsNeckoChild()) {
2532 // make sure PSM gets initialized on the main thread.
2533 net_EnsurePSMInit();
2534 }
2535 }
2536 // Ensure that this is HTTP or HTTPS, otherwise we don't do preconnect here
2537 else if (!scheme.EqualsLiteral("http")) {
2538 return NS_ERROR_UNEXPECTED;
2539 }
2540
2541 nsAutoCString host;
2542 rv = aURI->GetAsciiHost(host);
2543 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv;
2544
2545 int32_t port = -1;
2546 rv = aURI->GetPort(&port);
2547 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv;
2548
2549 nsAutoCString username;
2550 aURI->GetUsername(username);
2551
2552 RefPtr<AltSvcMapping> mapping;
2553 if (username.IsEmpty()) {
2554 mapping = gHttpHandler->GetAltServiceMapping(
2555 scheme, host, port, originAttributes.IsPrivateBrowsing(),
2556 originAttributes, true, true);
2557 }
2558
2559 RefPtr<nsHttpConnectionInfo> ci;
2560 if (mapping) {
2561 mapping->GetConnectionInfo(getter_AddRefs(ci), nullptr, originAttributes);
2562 } else {
2563 ci = new nsHttpConnectionInfo(host, port, ""_ns, username, nullptr,
2564 originAttributes, aURI->SchemeIs("https"));
2565 }
2566 ci = ci->Mutate()
2567 .SetAnonymous(anonymous)
2568 .SetPrivate(originAttributes.IsPrivateBrowsing())
2569 .Finalize();
2570
2571 if (mDebugObservations) {
2572 // this is basically used for test coverage of an otherwise 'hintable'
2573 // feature
2574
2575 nsCOMPtr<nsIObserverService> obsService = services::GetObserverService();
2576 if (obsService) {
2577 // This is used to test if the speculative connection has the right
2578 // connection info.
2579 nsPrintfCString debugHashKey("%s", ci->HashKey().get());
2580 obsService->NotifyObservers(nullptr, "speculative-connect-request",
2581 NS_ConvertUTF8toUTF16(debugHashKey).get());
2582 for (auto* cp :
2583 dom::ContentParent::AllProcesses(dom::ContentParent::eLive)) {
2584 PNeckoParent* neckoParent =
2585 SingleManagedOrNull(cp->ManagedPNeckoParent());
2586 if (!neckoParent) {
2587 continue;
2588 }
2589 (void)neckoParent->SendSpeculativeConnectRequest();
2590 }
2591 }
2592 }
2593
2594 bool fetchHTTPSRR = EchConfigEnabled();
2595 if (StaticPrefs::network_http_happy_eyeballs_enabled()) {
2596 ci = ci->Mutate().SetHappyEyeballsEnabled(true).Finalize();
2597 // When HE is enabled, HTTPS RR lookups are handled by
2598 // HappyEyeballsConnectionAttempt.
2599 fetchHTTPSRR = false;
2600 }
2601
2602 LOG(("MaybeSpeculativeConnectWithHTTPSRR for ci=%s", ci->HashKey().get()))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "MaybeSpeculativeConnectWithHTTPSRR for ci=%s"
, ci->HashKey().get()); } } while (0)
;
2603 // When ech is enabled, always do speculative connect with HTTPS RR.
2604 return MaybeSpeculativeConnectWithHTTPSRR(ci, aCallbacks, 0, fetchHTTPSRR);
2605}
2606
2607nsresult nsHttpHandler::SpeculativeConnect(nsHttpConnectionInfo* ci,
2608 nsIInterfaceRequestor* callbacks,
2609 uint32_t caps,
2610 SpeculativeTransaction* aTrans) {
2611 if (mDebugObservations) {
2612 nsCOMPtr<nsIObserverService> obsService = services::GetObserverService();
2613 if (obsService) {
2614 nsPrintfCString debugHashKey("%s", ci->HashKey().get());
2615 obsService->NotifyObservers(nullptr, "speculative-connect-request",
2616 NS_ConvertUTF8toUTF16(debugHashKey).get());
2617 }
2618 }
2619 return mConnMgr->SpeculativeConnect(ci, callbacks, caps, aTrans);
2620}
2621
2622NS_IMETHODIMPnsresult
2623nsHttpHandler::SpeculativeConnect(nsIURI* aURI, nsIPrincipal* aPrincipal,
2624 nsIInterfaceRequestor* aCallbacks,
2625 bool aAnonymous) {
2626 return SpeculativeConnectInternal(aURI, aPrincipal, Nothing(), aCallbacks,
2627 aAnonymous);
2628}
2629
2630NS_IMETHODIMPnsresult nsHttpHandler::SpeculativeConnectWithOriginAttributes(
2631 nsIURI* aURI, JS::Handle<JS::Value> aOriginAttributes,
2632 nsIInterfaceRequestor* aCallbacks, bool aAnonymous, JSContext* aCx) {
2633 OriginAttributes attrs;
2634 if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
2635 return NS_ERROR_INVALID_ARG;
2636 }
2637
2638 SpeculativeConnectWithOriginAttributesNative(aURI, std::move(attrs),
2639 aCallbacks, aAnonymous);
2640 return NS_OK;
2641}
2642
2643NS_IMETHODIMP_(void)void
2644nsHttpHandler::SpeculativeConnectWithOriginAttributesNative(
2645 nsIURI* aURI, OriginAttributes&& aOriginAttributes,
2646 nsIInterfaceRequestor* aCallbacks, bool aAnonymous) {
2647 Maybe<OriginAttributes> originAttributes;
2648 originAttributes.emplace(aOriginAttributes);
2649 (void)SpeculativeConnectInternal(aURI, nullptr, std::move(originAttributes),
2650 aCallbacks, aAnonymous);
2651}
2652
2653void nsHttpHandler::TickleWifi(nsIInterfaceRequestor* cb) {
2654 if (!cb || !mWifiTickler) return;
2655
2656 // If B2G requires a similar mechanism nsINetworkManager, currently only avail
2657 // on B2G, contains the necessary information on wifi and gateway
2658
2659 nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(cb);
2660 nsCOMPtr<nsPIDOMWindowOuter> piWindow = do_QueryInterface(domWindow);
2661 if (!piWindow) return;
2662
2663 RefPtr<dom::Navigator> navigator = piWindow->GetNavigator();
2664 if (!navigator) return;
2665
2666 RefPtr<dom::network::Connection> networkProperties =
2667 navigator->GetConnection(IgnoreErrors());
2668 if (!networkProperties) return;
2669
2670 uint32_t gwAddress = networkProperties->GetDhcpGateway();
2671 bool isWifi = networkProperties->GetIsWifi();
2672 if (!gwAddress || !isWifi) return;
2673
2674 mWifiTickler->SetIPV4Address(gwAddress);
2675 mWifiTickler->Tickle();
2676}
2677
2678//-----------------------------------------------------------------------------
2679// nsHttpsHandler implementation
2680//-----------------------------------------------------------------------------
2681
2682NS_IMPL_ISUPPORTS(nsHttpsHandler, nsIHttpProtocolHandler,MozExternalRefCountType nsHttpsHandler::AddRef(void) { static_assert
(!std::is_destructible_v<nsHttpsHandler>, "Reference-counted class "
"nsHttpsHandler" " should not have a public destructor. " "Make this class's destructor non-public"
); do { static_assert( mozilla::detail::AssertionConditionType
<decltype(int32_t(mRefCnt) >= 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(int32_t(mRefCnt) >= 0))),
0))) { do { } while (false); MOZ_ReportAssertionFailure("int32_t(mRefCnt) >= 0"
" (" "illegal refcnt" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2684); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0"
") (" "illegal refcnt" ")"); do { MOZ_CrashSequence(__null, 2684
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); do { static_assert( mozilla::detail::AssertionConditionType
<decltype("nsHttpsHandler" != nullptr)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!("nsHttpsHandler" != nullptr)
)), 0))) { do { } while (false); MOZ_ReportAssertionFailure("\"nsHttpsHandler\" != nullptr"
" (" "Must specify a name" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2684); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpsHandler\" != nullptr"
") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null
, 2684); __attribute__((nomerge)) ::abort(); } while (false);
} } while (false); if (!mRefCnt.isThreadSafe) _mOwningThread
.AssertOwnership("nsHttpsHandler" " not thread-safe"); nsrefcnt
count = ++mRefCnt; NS_LogAddRef((this), (count), ("nsHttpsHandler"
), (uint32_t)(sizeof(*this))); return count; } MozExternalRefCountType
nsHttpsHandler::Release(void) { do { static_assert( mozilla::
detail::AssertionConditionType<decltype(int32_t(mRefCnt) >
0)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(int32_t(mRefCnt) > 0))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("int32_t(mRefCnt) > 0" " (" "dup release"
")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2684); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0"
") (" "dup release" ")"); do { MOZ_CrashSequence(__null, 2684
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); do { static_assert( mozilla::detail::AssertionConditionType
<decltype("nsHttpsHandler" != nullptr)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!("nsHttpsHandler" != nullptr)
)), 0))) { do { } while (false); MOZ_ReportAssertionFailure("\"nsHttpsHandler\" != nullptr"
" (" "Must specify a name" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2684); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpsHandler\" != nullptr"
") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null
, 2684); __attribute__((nomerge)) ::abort(); } while (false);
} } while (false); if (!mRefCnt.isThreadSafe) _mOwningThread
.AssertOwnership("nsHttpsHandler" " not thread-safe"); const char
* const nametmp = "nsHttpsHandler"; nsrefcnt count = --mRefCnt
; NS_LogRelease((this), (count), (nametmp)); if (count == 0) {
mRefCnt = 1; delete (this); return 0; } return count; } nsresult
nsHttpsHandler::QueryInterface(const nsIID& aIID, void**
aInstancePtr) { do { if (!(aInstancePtr)) { NS_DebugBreak(NS_DEBUG_ASSERTION
, "QueryInterface requires a non-NULL destination!", "aInstancePtr"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2684); MOZ_PretendNoReturn(); } } while (0); nsresult rv = NS_ERROR_FAILURE
; static_assert(5 > 0, "Need more arguments to NS_INTERFACE_TABLE"
); static const QITableEntry table[] = { {&mozilla::detail
::kImplementedIID<nsHttpsHandler, nsIHttpProtocolHandler>
, int32_t( reinterpret_cast<char*>(static_cast<nsIHttpProtocolHandler
*>((nsHttpsHandler*)0x1000)) - reinterpret_cast<char*>
((nsHttpsHandler*)0x1000))}, {&mozilla::detail::kImplementedIID
<nsHttpsHandler, nsIProxiedProtocolHandler>, int32_t( reinterpret_cast
<char*>(static_cast<nsIProxiedProtocolHandler*>((
nsHttpsHandler*)0x1000)) - reinterpret_cast<char*>((nsHttpsHandler
*)0x1000))}, {&mozilla::detail::kImplementedIID<nsHttpsHandler
, nsIProtocolHandler>, int32_t( reinterpret_cast<char*>
(static_cast<nsIProtocolHandler*>((nsHttpsHandler*)0x1000
)) - reinterpret_cast<char*>((nsHttpsHandler*)0x1000))}
, {&mozilla::detail::kImplementedIID<nsHttpsHandler, nsISupportsWeakReference
>, int32_t( reinterpret_cast<char*>(static_cast<nsISupportsWeakReference
*>((nsHttpsHandler*)0x1000)) - reinterpret_cast<char*>
((nsHttpsHandler*)0x1000))}, {&mozilla::detail::kImplementedIID
<nsHttpsHandler, nsISpeculativeConnect>, int32_t( reinterpret_cast
<char*>(static_cast<nsISpeculativeConnect*>((nsHttpsHandler
*)0x1000)) - reinterpret_cast<char*>((nsHttpsHandler*)0x1000
))}, {&mozilla::detail::kImplementedIID<nsHttpsHandler
, nsISupports>, int32_t(reinterpret_cast<char*>(static_cast
<nsISupports*>( static_cast<nsIHttpProtocolHandler*>
((nsHttpsHandler*)0x1000))) - reinterpret_cast<char*>((
nsHttpsHandler*)0x1000))}, { nullptr, 0 } } ; static_assert(std
::size(table) > 1, "need at least 1 interface"); rv = NS_TableDrivenQI
(static_cast<void*>(this), aIID, aInstancePtr, table); return
rv; }
2683 nsIProxiedProtocolHandler, nsIProtocolHandler,MozExternalRefCountType nsHttpsHandler::AddRef(void) { static_assert
(!std::is_destructible_v<nsHttpsHandler>, "Reference-counted class "
"nsHttpsHandler" " should not have a public destructor. " "Make this class's destructor non-public"
); do { static_assert( mozilla::detail::AssertionConditionType
<decltype(int32_t(mRefCnt) >= 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(int32_t(mRefCnt) >= 0))),
0))) { do { } while (false); MOZ_ReportAssertionFailure("int32_t(mRefCnt) >= 0"
" (" "illegal refcnt" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2684); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0"
") (" "illegal refcnt" ")"); do { MOZ_CrashSequence(__null, 2684
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); do { static_assert( mozilla::detail::AssertionConditionType
<decltype("nsHttpsHandler" != nullptr)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!("nsHttpsHandler" != nullptr)
)), 0))) { do { } while (false); MOZ_ReportAssertionFailure("\"nsHttpsHandler\" != nullptr"
" (" "Must specify a name" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2684); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpsHandler\" != nullptr"
") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null
, 2684); __attribute__((nomerge)) ::abort(); } while (false);
} } while (false); if (!mRefCnt.isThreadSafe) _mOwningThread
.AssertOwnership("nsHttpsHandler" " not thread-safe"); nsrefcnt
count = ++mRefCnt; NS_LogAddRef((this), (count), ("nsHttpsHandler"
), (uint32_t)(sizeof(*this))); return count; } MozExternalRefCountType
nsHttpsHandler::Release(void) { do { static_assert( mozilla::
detail::AssertionConditionType<decltype(int32_t(mRefCnt) >
0)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(int32_t(mRefCnt) > 0))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("int32_t(mRefCnt) > 0" " (" "dup release"
")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2684); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0"
") (" "dup release" ")"); do { MOZ_CrashSequence(__null, 2684
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); do { static_assert( mozilla::detail::AssertionConditionType
<decltype("nsHttpsHandler" != nullptr)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!("nsHttpsHandler" != nullptr)
)), 0))) { do { } while (false); MOZ_ReportAssertionFailure("\"nsHttpsHandler\" != nullptr"
" (" "Must specify a name" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2684); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpsHandler\" != nullptr"
") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null
, 2684); __attribute__((nomerge)) ::abort(); } while (false);
} } while (false); if (!mRefCnt.isThreadSafe) _mOwningThread
.AssertOwnership("nsHttpsHandler" " not thread-safe"); const char
* const nametmp = "nsHttpsHandler"; nsrefcnt count = --mRefCnt
; NS_LogRelease((this), (count), (nametmp)); if (count == 0) {
mRefCnt = 1; delete (this); return 0; } return count; } nsresult
nsHttpsHandler::QueryInterface(const nsIID& aIID, void**
aInstancePtr) { do { if (!(aInstancePtr)) { NS_DebugBreak(NS_DEBUG_ASSERTION
, "QueryInterface requires a non-NULL destination!", "aInstancePtr"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2684); MOZ_PretendNoReturn(); } } while (0); nsresult rv = NS_ERROR_FAILURE
; static_assert(5 > 0, "Need more arguments to NS_INTERFACE_TABLE"
); static const QITableEntry table[] = { {&mozilla::detail
::kImplementedIID<nsHttpsHandler, nsIHttpProtocolHandler>
, int32_t( reinterpret_cast<char*>(static_cast<nsIHttpProtocolHandler
*>((nsHttpsHandler*)0x1000)) - reinterpret_cast<char*>
((nsHttpsHandler*)0x1000))}, {&mozilla::detail::kImplementedIID
<nsHttpsHandler, nsIProxiedProtocolHandler>, int32_t( reinterpret_cast
<char*>(static_cast<nsIProxiedProtocolHandler*>((
nsHttpsHandler*)0x1000)) - reinterpret_cast<char*>((nsHttpsHandler
*)0x1000))}, {&mozilla::detail::kImplementedIID<nsHttpsHandler
, nsIProtocolHandler>, int32_t( reinterpret_cast<char*>
(static_cast<nsIProtocolHandler*>((nsHttpsHandler*)0x1000
)) - reinterpret_cast<char*>((nsHttpsHandler*)0x1000))}
, {&mozilla::detail::kImplementedIID<nsHttpsHandler, nsISupportsWeakReference
>, int32_t( reinterpret_cast<char*>(static_cast<nsISupportsWeakReference
*>((nsHttpsHandler*)0x1000)) - reinterpret_cast<char*>
((nsHttpsHandler*)0x1000))}, {&mozilla::detail::kImplementedIID
<nsHttpsHandler, nsISpeculativeConnect>, int32_t( reinterpret_cast
<char*>(static_cast<nsISpeculativeConnect*>((nsHttpsHandler
*)0x1000)) - reinterpret_cast<char*>((nsHttpsHandler*)0x1000
))}, {&mozilla::detail::kImplementedIID<nsHttpsHandler
, nsISupports>, int32_t(reinterpret_cast<char*>(static_cast
<nsISupports*>( static_cast<nsIHttpProtocolHandler*>
((nsHttpsHandler*)0x1000))) - reinterpret_cast<char*>((
nsHttpsHandler*)0x1000))}, { nullptr, 0 } } ; static_assert(std
::size(table) > 1, "need at least 1 interface"); rv = NS_TableDrivenQI
(static_cast<void*>(this), aIID, aInstancePtr, table); return
rv; }
2684 nsISupportsWeakReference, nsISpeculativeConnect)MozExternalRefCountType nsHttpsHandler::AddRef(void) { static_assert
(!std::is_destructible_v<nsHttpsHandler>, "Reference-counted class "
"nsHttpsHandler" " should not have a public destructor. " "Make this class's destructor non-public"
); do { static_assert( mozilla::detail::AssertionConditionType
<decltype(int32_t(mRefCnt) >= 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(int32_t(mRefCnt) >= 0))),
0))) { do { } while (false); MOZ_ReportAssertionFailure("int32_t(mRefCnt) >= 0"
" (" "illegal refcnt" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2684); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0"
") (" "illegal refcnt" ")"); do { MOZ_CrashSequence(__null, 2684
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); do { static_assert( mozilla::detail::AssertionConditionType
<decltype("nsHttpsHandler" != nullptr)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!("nsHttpsHandler" != nullptr)
)), 0))) { do { } while (false); MOZ_ReportAssertionFailure("\"nsHttpsHandler\" != nullptr"
" (" "Must specify a name" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2684); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpsHandler\" != nullptr"
") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null
, 2684); __attribute__((nomerge)) ::abort(); } while (false);
} } while (false); if (!mRefCnt.isThreadSafe) _mOwningThread
.AssertOwnership("nsHttpsHandler" " not thread-safe"); nsrefcnt
count = ++mRefCnt; NS_LogAddRef((this), (count), ("nsHttpsHandler"
), (uint32_t)(sizeof(*this))); return count; } MozExternalRefCountType
nsHttpsHandler::Release(void) { do { static_assert( mozilla::
detail::AssertionConditionType<decltype(int32_t(mRefCnt) >
0)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(int32_t(mRefCnt) > 0))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("int32_t(mRefCnt) > 0" " (" "dup release"
")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2684); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0"
") (" "dup release" ")"); do { MOZ_CrashSequence(__null, 2684
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false); do { static_assert( mozilla::detail::AssertionConditionType
<decltype("nsHttpsHandler" != nullptr)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!("nsHttpsHandler" != nullptr)
)), 0))) { do { } while (false); MOZ_ReportAssertionFailure("\"nsHttpsHandler\" != nullptr"
" (" "Must specify a name" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2684); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpsHandler\" != nullptr"
") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null
, 2684); __attribute__((nomerge)) ::abort(); } while (false);
} } while (false); if (!mRefCnt.isThreadSafe) _mOwningThread
.AssertOwnership("nsHttpsHandler" " not thread-safe"); const char
* const nametmp = "nsHttpsHandler"; nsrefcnt count = --mRefCnt
; NS_LogRelease((this), (count), (nametmp)); if (count == 0) {
mRefCnt = 1; delete (this); return 0; } return count; } nsresult
nsHttpsHandler::QueryInterface(const nsIID& aIID, void**
aInstancePtr) { do { if (!(aInstancePtr)) { NS_DebugBreak(NS_DEBUG_ASSERTION
, "QueryInterface requires a non-NULL destination!", "aInstancePtr"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2684); MOZ_PretendNoReturn(); } } while (0); nsresult rv = NS_ERROR_FAILURE
; static_assert(5 > 0, "Need more arguments to NS_INTERFACE_TABLE"
); static const QITableEntry table[] = { {&mozilla::detail
::kImplementedIID<nsHttpsHandler, nsIHttpProtocolHandler>
, int32_t( reinterpret_cast<char*>(static_cast<nsIHttpProtocolHandler
*>((nsHttpsHandler*)0x1000)) - reinterpret_cast<char*>
((nsHttpsHandler*)0x1000))}, {&mozilla::detail::kImplementedIID
<nsHttpsHandler, nsIProxiedProtocolHandler>, int32_t( reinterpret_cast
<char*>(static_cast<nsIProxiedProtocolHandler*>((
nsHttpsHandler*)0x1000)) - reinterpret_cast<char*>((nsHttpsHandler
*)0x1000))}, {&mozilla::detail::kImplementedIID<nsHttpsHandler
, nsIProtocolHandler>, int32_t( reinterpret_cast<char*>
(static_cast<nsIProtocolHandler*>((nsHttpsHandler*)0x1000
)) - reinterpret_cast<char*>((nsHttpsHandler*)0x1000))}
, {&mozilla::detail::kImplementedIID<nsHttpsHandler, nsISupportsWeakReference
>, int32_t( reinterpret_cast<char*>(static_cast<nsISupportsWeakReference
*>((nsHttpsHandler*)0x1000)) - reinterpret_cast<char*>
((nsHttpsHandler*)0x1000))}, {&mozilla::detail::kImplementedIID
<nsHttpsHandler, nsISpeculativeConnect>, int32_t( reinterpret_cast
<char*>(static_cast<nsISpeculativeConnect*>((nsHttpsHandler
*)0x1000)) - reinterpret_cast<char*>((nsHttpsHandler*)0x1000
))}, {&mozilla::detail::kImplementedIID<nsHttpsHandler
, nsISupports>, int32_t(reinterpret_cast<char*>(static_cast
<nsISupports*>( static_cast<nsIHttpProtocolHandler*>
((nsHttpsHandler*)0x1000))) - reinterpret_cast<char*>((
nsHttpsHandler*)0x1000))}, { nullptr, 0 } } ; static_assert(std
::size(table) > 1, "need at least 1 interface"); rv = NS_TableDrivenQI
(static_cast<void*>(this), aIID, aInstancePtr, table); return
rv; }
2685
2686nsresult nsHttpsHandler::Init() {
2687 nsCOMPtr<nsIProtocolHandler> httpHandler(
2688 do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX"@mozilla.org/network/protocol;1?name=" "http"));
2689 MOZ_ASSERT(httpHandler.get() != nullptr)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(httpHandler.get() != nullptr)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(httpHandler.get() != nullptr
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"httpHandler.get() != nullptr", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2689); AnnotateMozCrashReason("MOZ_ASSERT" "(" "httpHandler.get() != nullptr"
")"); do { MOZ_CrashSequence(__null, 2689); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2690 return NS_OK;
2691}
2692
2693NS_IMETHODIMPnsresult
2694nsHttpsHandler::GetScheme(nsACString& aScheme) {
2695 aScheme.AssignLiteral("https");
2696 return NS_OK;
2697}
2698
2699NS_IMETHODIMPnsresult
2700nsHttpsHandler::NewChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo,
2701 nsIChannel** _retval) {
2702 MOZ_ASSERT(gHttpHandler)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(gHttpHandler)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(gHttpHandler))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("gHttpHandler", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2702); AnnotateMozCrashReason("MOZ_ASSERT" "(" "gHttpHandler"
")"); do { MOZ_CrashSequence(__null, 2702); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2703 if (!gHttpHandler) return NS_ERROR_UNEXPECTED;
2704 return gHttpHandler->NewChannel(aURI, aLoadInfo, _retval);
2705}
2706
2707NS_IMETHODIMPnsresult
2708nsHttpsHandler::AllowPort(int32_t aPort, const char* aScheme, bool* _retval) {
2709 // don't override anything.
2710 *_retval = false;
2711 return NS_OK;
2712}
2713
2714NS_IMETHODIMPnsresult
2715nsHttpHandler::EnsureHSTSDataReadyNative(
2716 RefPtr<mozilla::net::HSTSDataCallbackWrapper> aCallback) {
2717 MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(NS_IsMainThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2717); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()"
")"); do { MOZ_CrashSequence(__null, 2717); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2718
2719 nsCOMPtr<nsIURI> uri;
2720 nsresult rv = NS_NewURI(getter_AddRefs(uri), "http://example.com");
2721 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2721); return rv; } } while (false)
;
2722
2723 bool shouldUpgrade = false;
2724 bool willCallback = false;
2725 OriginAttributes originAttributes;
2726 auto func = [callback(aCallback)](bool aResult, nsresult aStatus) {
2727 callback->DoCallback(aResult);
2728 };
2729 rv = NS_ShouldSecureUpgrade(uri, nullptr, nullptr, nullptr, false,
2730 originAttributes, shouldUpgrade, std::move(func),
2731 willCallback);
2732 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0))) || !willCallback) {
2733 aCallback->DoCallback(false);
2734 return rv;
2735 }
2736
2737 return rv;
2738}
2739
2740NS_IMETHODIMPnsresult
2741nsHttpHandler::EnsureHSTSDataReady(JSContext* aCx, Promise** aPromise) {
2742 if (NS_WARN_IF(!aCx)NS_warn_if_impl(!aCx, "!aCx", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2742)
) {
2743 return NS_ERROR_FAILURE;
2744 }
2745
2746 nsIGlobalObject* globalObject = xpc::CurrentNativeGlobal(aCx);
2747 if (NS_WARN_IF(!globalObject)NS_warn_if_impl(!globalObject, "!globalObject", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2747)
) {
2748 return NS_ERROR_FAILURE;
2749 }
2750
2751 ErrorResult result;
2752 RefPtr<Promise> promise = Promise::Create(globalObject, result);
2753 if (NS_WARN_IF(result.Failed())NS_warn_if_impl(result.Failed(), "result.Failed()", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2753)
) {
2754 return result.StealNSResult();
2755 }
2756
2757 if (IsNeckoChild()) {
2758 gNeckoChild->SendEnsureHSTSData()->Then(
2759 GetMainThreadSerialEventTarget(), __func__,
2760 [promise(promise)](
2761 NeckoChild::EnsureHSTSDataPromise::ResolveOrRejectValue&& aResult) {
2762 if (aResult.IsResolve()) {
2763 promise->MaybeResolve(aResult.ResolveValue());
2764 } else {
2765 promise->MaybeReject(NS_ERROR_FAILURE);
2766 }
2767 });
2768 promise.forget(aPromise);
2769 return NS_OK;
2770 }
2771
2772 auto callback = [promise(promise)](bool aResult) {
2773 promise->MaybeResolve(aResult);
2774 };
2775
2776 RefPtr<HSTSDataCallbackWrapper> wrapper =
2777 new HSTSDataCallbackWrapper(std::move(callback));
2778 promise.forget(aPromise);
2779 return EnsureHSTSDataReadyNative(wrapper);
2780}
2781
2782NS_IMETHODIMPnsresult
2783nsHttpHandler::ClearCORSPreflightCache() {
2784 nsCORSListenerProxy::ClearCache();
2785 return NS_OK;
2786}
2787
2788void nsHttpHandler::ShutdownConnectionManager() {
2789 // ensure connection manager is shutdown
2790 if (mConnMgr) {
2791 nsresult rv = mConnMgr->Shutdown();
2792 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
2793 LOG(do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::ShutdownConnectionManager\n"
" failed to shutdown connection manager\n"); } } while (0
)
2794 ("nsHttpHandler::ShutdownConnectionManager\n"do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::ShutdownConnectionManager\n"
" failed to shutdown connection manager\n"); } } while (0
)
2795 " failed to shutdown connection manager\n"))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::ShutdownConnectionManager\n"
" failed to shutdown connection manager\n"); } } while (0
)
;
2796 }
2797 }
2798}
2799
2800uint64_t nsHttpHandler::NewChannelId() {
2801 // channelId is sometimes passed to JavaScript code (e.g. devtools),
2802 // values should not exceed safe JavaScript integer range (2^53 – 1).
2803 // Since the uniqueProcessId starts at 0, this should be safe to use
2804 // unless we create more than 2^22 processes.
2805 return ((mUniqueProcessId << 31) & 0xFFFFFFFF80000000LL) | mNextChannelId++;
2806}
2807
2808void nsHttpHandler::NotifyActiveTabLoadOptimization() {
2809 SetLastActiveTabLoadOptimizationHit(TimeStamp::Now());
2810}
2811
2812TimeStamp nsHttpHandler::GetLastActiveTabLoadOptimizationHit() {
2813 auto lastTimestamp = mLastActiveTabLoadOptimizationHit.Lock();
2814 return *lastTimestamp;
2815}
2816
2817void nsHttpHandler::SetLastActiveTabLoadOptimizationHit(TimeStamp const& when) {
2818 if (when.IsNull()) {
2819 return;
2820 }
2821 auto lastTimestamp = mLastActiveTabLoadOptimizationHit.Lock();
2822 if (lastTimestamp->IsNull() || *lastTimestamp < when) {
2823 *lastTimestamp = when;
2824 }
2825}
2826
2827bool nsHttpHandler::IsBeforeLastActiveTabLoadOptimization(
2828 TimeStamp const& when) {
2829 auto lastTimestamp = mLastActiveTabLoadOptimizationHit.Lock();
2830 return !lastTimestamp->IsNull() && when <= *lastTimestamp;
2831}
2832
2833void nsHttpHandler::ExcludeHttp2OrHttp3Internal(nsHttpConnectionInfo* ci) {
2834 if (ci->GetHappyEyeballsEnabled()) {
2835 return;
2836 }
2837 LOG(("nsHttpHandler::ExcludeHttp2OrHttp3Internal ci=%s",do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::ExcludeHttp2OrHttp3Internal ci=%s"
, ci->HashKey().get()); } } while (0)
2838 ci->HashKey().get()))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::ExcludeHttp2OrHttp3Internal ci=%s"
, ci->HashKey().get()); } } while (0)
;
2839 // The excluded list needs to be stayed synced between parent process and
2840 // socket process, so we send this information to the parent process here.
2841 if (XRE_IsSocketProcess()) {
2842 MOZ_ASSERT(OnSocketThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(OnSocketThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(OnSocketThread()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("OnSocketThread()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2842); AnnotateMozCrashReason("MOZ_ASSERT" "(" "OnSocketThread()"
")"); do { MOZ_CrashSequence(__null, 2842); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2843
2844 RefPtr<nsHttpConnectionInfo> cinfo = ci;
2845 NS_DispatchToMainThread(NS_NewRunnableFunction(
2846 "nsHttpHandler::ExcludeHttp2OrHttp3Internal",
2847 [cinfo{std::move(cinfo)}]() {
2848 HttpConnectionInfoCloneArgs connInfoArgs;
2849 nsHttpConnectionInfo::SerializeHttpConnectionInfo(cinfo,
2850 connInfoArgs);
2851 (void)SocketProcessChild::GetSingleton()->SendExcludeHttp2OrHttp3(
2852 connInfoArgs);
2853 }));
2854 }
2855
2856 MOZ_ASSERT_IF(nsIOService::UseSocketProcess() && XRE_IsParentProcess(),do { if (nsIOService::UseSocketProcess() && XRE_IsParentProcess
()) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(NS_IsMainThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2857); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()"
")"); do { MOZ_CrashSequence(__null, 2857); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
2857 NS_IsMainThread())do { if (nsIOService::UseSocketProcess() && XRE_IsParentProcess
()) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(NS_IsMainThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2857); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()"
")"); do { MOZ_CrashSequence(__null, 2857); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
2858 MOZ_ASSERT_IF(!nsIOService::UseSocketProcess(), OnSocketThread())do { if (!nsIOService::UseSocketProcess()) { do { static_assert
( mozilla::detail::AssertionConditionType<decltype(OnSocketThread
())>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(OnSocketThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("OnSocketThread()", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2858); AnnotateMozCrashReason("MOZ_ASSERT" "(" "OnSocketThread()"
")"); do { MOZ_CrashSequence(__null, 2858); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
2859
2860 if (ci->IsHttp3()) {
2861 {
2862 MutexAutoLock lock(mHttpExclusionLock);
2863 mExcludedHttp3Origins.Insert(ci->GetRoutedHost());
2864 }
2865 mConnMgr->ExcludeHttp3(ci);
2866 } else {
2867 {
2868 MutexAutoLock lock(mHttpExclusionLock);
2869 mExcludedHttp2Origins.Insert(ci->GetOrigin());
2870 }
2871 mConnMgr->ExcludeHttp2(ci);
2872 }
2873}
2874
2875void nsHttpHandler::ExcludeHttp2(nsHttpConnectionInfo* ci) {
2876 ExcludeHttp2OrHttp3Internal(ci);
2877}
2878
2879bool nsHttpHandler::IsHttp2Excluded(const nsHttpConnectionInfo* ci) {
2880 MutexAutoLock lock(mHttpExclusionLock);
2881 return mExcludedHttp2Origins.Contains(ci->GetOrigin());
2882}
2883
2884void nsHttpHandler::ExcludeHttp3(nsHttpConnectionInfo* ci) {
2885 // TODO: exclude HTTP/3 for proxy connection properly.
2886 if (ci->IsHttp3ProxyConnection()) {
2887 return;
2888 }
2889 MOZ_ASSERT(ci->IsHttp3())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(ci->IsHttp3())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(ci->IsHttp3()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("ci->IsHttp3()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2889); AnnotateMozCrashReason("MOZ_ASSERT" "(" "ci->IsHttp3()"
")"); do { MOZ_CrashSequence(__null, 2889); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2890 ExcludeHttp2OrHttp3Internal(ci);
2891}
2892
2893bool nsHttpHandler::IsHttp3Excluded(const nsACString& aRoutedHost) {
2894 MutexAutoLock lock(mHttpExclusionLock);
2895 return mExcludedHttp3Origins.Contains(aRoutedHost);
2896}
2897
2898HttpTrafficAnalyzer* nsHttpHandler::GetHttpTrafficAnalyzer() {
2899 MOZ_ASSERT(OnSocketThread(), "not on socket thread")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(OnSocketThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(OnSocketThread()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("OnSocketThread()"
" (" "not on socket thread" ")", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2899); AnnotateMozCrashReason("MOZ_ASSERT" "(" "OnSocketThread()"
") (" "not on socket thread" ")"); do { MOZ_CrashSequence(__null
, 2899); __attribute__((nomerge)) ::abort(); } while (false);
} } while (false)
;
2900
2901 if (!StaticPrefs::network_traffic_analyzer_enabled()) {
2902 return nullptr;
2903 }
2904
2905 return &mHttpTrafficAnalyzer;
2906}
2907
2908bool nsHttpHandler::IsHttp3Enabled() {
2909 static const uint32_t TLS3_PREF_VALUE = 4;
2910
2911 return StaticPrefs::network_http_http3_enable() &&
2912 (StaticPrefs::security_tls_version_max() >= TLS3_PREF_VALUE);
2913}
2914
2915bool nsHttpHandler::IsHttp3VersionSupported(const nsACString& version) {
2916 return (StaticPrefs::network_http_http3_support_version1() &&
2917 version.EqualsLiteral("h3"));
2918}
2919
2920bool nsHttpHandler::IsHttp3SupportedByServer(
2921 nsHttpResponseHead* aResponseHead) {
2922 if ((aResponseHead->Version() != HttpVersion::v2_0) ||
2923 (aResponseHead->Status() >= 500) || (aResponseHead->Status() == 421)) {
2924 return false;
2925 }
2926
2927 nsAutoCString altSvc;
2928 (void)aResponseHead->GetHeader(nsHttp::Alternate_Service, altSvc);
2929 if (altSvc.IsEmpty() || !nsHttp::IsReasonableHeaderValue(altSvc)) {
2930 return false;
2931 }
2932
2933 return altSvc.Find("h3=") != -1;
2934}
2935
2936nsresult nsHttpHandler::InitiateTransaction(HttpTransactionShell* aTrans,
2937 int32_t aPriority) {
2938 return mConnMgr->AddTransaction(aTrans, aPriority);
2939}
2940nsresult nsHttpHandler::InitiateTransactionWithStickyConn(
2941 HttpTransactionShell* aTrans, int32_t aPriority,
2942 HttpTransactionShell* aTransWithStickyConn) {
2943 return mConnMgr->AddTransactionWithStickyConn(aTrans, aPriority,
2944 aTransWithStickyConn);
2945}
2946
2947nsresult nsHttpHandler::RescheduleTransaction(HttpTransactionShell* trans,
2948 int32_t priority) {
2949 return mConnMgr->RescheduleTransaction(trans, priority);
2950}
2951
2952void nsHttpHandler::UpdateClassOfServiceOnTransaction(
2953 HttpTransactionShell* trans, const ClassOfService& classOfService) {
2954 mConnMgr->UpdateClassOfServiceOnTransaction(trans, classOfService);
2955}
2956
2957nsresult nsHttpHandler::CancelTransaction(HttpTransactionShell* trans,
2958 nsresult reason) {
2959 return mConnMgr->CancelTransaction(trans, reason);
2960}
2961
2962void nsHttpHandler::AddHttpChannel(uint64_t aId, nsISupports* aChannel) {
2963 MOZ_ASSERT(XRE_IsParentProcess())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(XRE_IsParentProcess())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(XRE_IsParentProcess()))), 0)
)) { do { } while (false); MOZ_ReportAssertionFailure("XRE_IsParentProcess()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2963); AnnotateMozCrashReason("MOZ_ASSERT" "(" "XRE_IsParentProcess()"
")"); do { MOZ_CrashSequence(__null, 2963); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2964 MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(NS_IsMainThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2964); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()"
")"); do { MOZ_CrashSequence(__null, 2964); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2965
2966 nsWeakPtr channel(do_GetWeakReference(aChannel));
2967 mIDToHttpChannelMap.InsertOrUpdate(aId, std::move(channel));
2968}
2969
2970void nsHttpHandler::RemoveHttpChannel(uint64_t aId) {
2971 MOZ_ASSERT(XRE_IsParentProcess())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(XRE_IsParentProcess())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(XRE_IsParentProcess()))), 0)
)) { do { } while (false); MOZ_ReportAssertionFailure("XRE_IsParentProcess()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2971); AnnotateMozCrashReason("MOZ_ASSERT" "(" "XRE_IsParentProcess()"
")"); do { MOZ_CrashSequence(__null, 2971); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2972 if (!NS_IsMainThread()) {
2973 nsCOMPtr<nsIRunnable> idleRunnable(NewCancelableRunnableMethod<uint64_t>(
2974 "nsHttpHandler::RemoveHttpChannel", this,
2975 &nsHttpHandler::RemoveHttpChannel, aId));
2976
2977 NS_DispatchToMainThreadQueue(do_AddRef(idleRunnable),
2978 EventQueuePriority::Idle);
2979 return;
2980 }
2981
2982 auto entry = mIDToHttpChannelMap.Lookup(aId);
2983 if (entry) {
2984 entry.Remove();
2985 }
2986}
2987
2988nsWeakPtr nsHttpHandler::GetWeakHttpChannel(uint64_t aId) {
2989 MOZ_ASSERT(XRE_IsParentProcess())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(XRE_IsParentProcess())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(XRE_IsParentProcess()))), 0)
)) { do { } while (false); MOZ_ReportAssertionFailure("XRE_IsParentProcess()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2989); AnnotateMozCrashReason("MOZ_ASSERT" "(" "XRE_IsParentProcess()"
")"); do { MOZ_CrashSequence(__null, 2989); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2990 MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(NS_IsMainThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 2990); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()"
")"); do { MOZ_CrashSequence(__null, 2990); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2991
2992 return mIDToHttpChannelMap.Get(aId);
2993}
2994
2995nsresult nsHttpHandler::CompleteUpgrade(
2996 HttpTransactionShell* aTrans, nsIHttpUpgradeListener* aUpgradeListener) {
2997 return mConnMgr->CompleteUpgrade(aTrans, aUpgradeListener);
2998}
2999
3000nsresult nsHttpHandler::DoShiftReloadConnectionCleanupWithConnInfo(
3001 nsHttpConnectionInfo* aCi) {
3002 MOZ_ASSERT(aCi)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aCi)>::isValid, "invalid assertion condition"); if
((__builtin_expect(!!(!(!!(aCi))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("aCi", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 3002); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aCi" ")"); do
{ MOZ_CrashSequence(__null, 3002); __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
;
3003 return mConnMgr->DoShiftReloadConnectionCleanupWithConnInfo(aCi);
3004}
3005
3006void nsHttpHandler::ClearHostMapping(nsHttpConnectionInfo* aConnInfo) {
3007 if (XRE_IsSocketProcess()) {
3008 AltServiceChild::ClearHostMapping(aConnInfo);
3009 return;
3010 }
3011
3012 AltServiceCache()->ClearHostMapping(aConnInfo);
3013}
3014
3015void nsHttpHandler::SetHttpHandlerInitArgs(const HttpHandlerInitArgs& aArgs) {
3016 MOZ_ASSERT(XRE_IsSocketProcess())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(XRE_IsSocketProcess())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(XRE_IsSocketProcess()))), 0)
)) { do { } while (false); MOZ_ReportAssertionFailure("XRE_IsSocketProcess()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 3016); AnnotateMozCrashReason("MOZ_ASSERT" "(" "XRE_IsSocketProcess()"
")"); do { MOZ_CrashSequence(__null, 3016); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3017 mLegacyAppName = aArgs.mLegacyAppName();
3018 mLegacyAppVersion = aArgs.mLegacyAppVersion();
3019 mPlatform = aArgs.mPlatform();
3020 mOscpu = aArgs.mOscpu();
3021 mMisc = aArgs.mMisc();
3022 mProduct = aArgs.mProduct();
3023 mProductSub = aArgs.mProductSub();
3024 mAppName = aArgs.mAppName();
3025 mAppVersion = aArgs.mAppVersion();
3026 mCompatFirefox = aArgs.mCompatFirefox();
3027 mCompatDevice = aArgs.mCompatDevice();
3028 mDeviceModelId = aArgs.mDeviceModelId();
3029 mUserAgentIsDirty = true;
3030}
3031
3032void nsHttpHandler::SetDeviceModelId(const nsACString& aModelId) {
3033 MOZ_ASSERT(XRE_IsSocketProcess())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(XRE_IsSocketProcess())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(XRE_IsSocketProcess()))), 0)
)) { do { } while (false); MOZ_ReportAssertionFailure("XRE_IsSocketProcess()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 3033); AnnotateMozCrashReason("MOZ_ASSERT" "(" "XRE_IsSocketProcess()"
")"); do { MOZ_CrashSequence(__null, 3033); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3034 mDeviceModelId = aModelId;
3035}
3036
3037void nsHttpHandler::MaybeAddAltSvcForTesting(
3038 nsIURI* aUri, const nsACString& aUsername, bool aPrivateBrowsing,
3039 nsIInterfaceRequestor* aCallbacks,
3040 const OriginAttributes& aOriginAttributes) {
3041 if (!IsHttp3Enabled()) {
3042 return;
3043 }
3044
3045 if (!aUri->SchemeIs("https")) {
3046 // Only set for HTTPS.
3047 return;
3048 }
3049
3050 nsAutoCString originHost;
3051 if (NS_FAILED(aUri->GetAsciiHost(originHost))((bool)(__builtin_expect(!!(NS_FAILED_impl(aUri->GetAsciiHost
(originHost))), 0)))
) {
3052 return;
3053 }
3054
3055 nsCString map;
3056 {
3057 auto mappings = mAltSvcMappingTemptativeMap.Lock();
3058 nsCString* found = mappings->Get(originHost);
3059 if (!found) {
3060 return;
3061 }
3062 map = *found;
3063 }
3064
3065 int32_t originPort = 80;
3066 aUri->GetPort(&originPort);
3067 LOG(("nsHttpHandler::MaybeAddAltSvcForTesting for %s map: %s",do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::MaybeAddAltSvcForTesting for %s map: %s"
, originHost.get(), map.get()); } } while (0)
3068 originHost.get(), map.get()))do { const ::mozilla::LogModule* moz_real_module = mozilla::net
::gHttpLog; if ((__builtin_expect(!!(mozilla::detail::log_test
(moz_real_module, mozilla::LogLevel::Debug)), 0))) { mozilla::
detail::log_print(moz_real_module, mozilla::LogLevel::Debug, "nsHttpHandler::MaybeAddAltSvcForTesting for %s map: %s"
, originHost.get(), map.get()); } } while (0)
;
3069 AltSvcMapping::ProcessHeader(map, "https"_ns, originHost, originPort,
3070 aUsername, aPrivateBrowsing, aCallbacks, nullptr,
3071 0, aOriginAttributes, nullptr, true);
3072}
3073
3074bool nsHttpHandler::EchConfigEnabled(bool aIsHttp3) {
3075 if (sParentalControlsEnabled) {
3076 return false;
3077 }
3078
3079 if (!aIsHttp3) {
3080 return StaticPrefs::network_dns_echconfig_enabled();
3081 }
3082
3083 return StaticPrefs::network_dns_http3_echconfig_enabled();
3084}
3085
3086bool nsHttpHandler::FallbackToOriginIfConfigsAreECHAndAllFailed() const {
3087 return StaticPrefs::
3088 network_dns_echconfig_fallback_to_origin_when_all_failed();
3089}
3090
3091void nsHttpHandler::ExcludeHTTPSRRHost(const nsACString& aHost) {
3092 MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(NS_IsMainThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 3092); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()"
")"); do { MOZ_CrashSequence(__null, 3092); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3093
3094 mExcludedHostsForHTTPSRRUpgrade.Insert(aHost);
3095}
3096
3097bool nsHttpHandler::IsHostExcludedForHTTPSRR(const nsACString& aHost) {
3098 MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(NS_IsMainThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 3098); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()"
")"); do { MOZ_CrashSequence(__null, 3098); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3099
3100 return mExcludedHostsForHTTPSRRUpgrade.Contains(aHost);
3101}
3102
3103#ifdef XP_MACOSX
3104bool nsHttpHandler::IsHostMSAuthority(const nsACString& aHost) {
3105 MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(NS_IsMainThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 3105); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()"
")"); do { MOZ_CrashSequence(__null, 3105); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3106
3107 return mMSAuthorities.Contains(aHost);
3108}
3109#endif
3110
3111void nsHttpHandler::Exclude0RttTcp(const nsHttpConnectionInfo* ci) {
3112 MOZ_ASSERT(OnSocketThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(OnSocketThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(OnSocketThread()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("OnSocketThread()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 3112); AnnotateMozCrashReason("MOZ_ASSERT" "(" "OnSocketThread()"
")"); do { MOZ_CrashSequence(__null, 3112); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3113
3114 if (!StaticPrefs::network_http_early_data_disable_on_error() ||
3115 (mExcluded0RttTcpOrigins.Count() >=
3116 StaticPrefs::network_http_early_data_max_error())) {
3117 return;
3118 }
3119
3120 mExcluded0RttTcpOrigins.Insert(ci->GetOrigin());
3121}
3122
3123bool nsHttpHandler::Is0RttTcpExcluded(const nsHttpConnectionInfo* ci) {
3124 MOZ_ASSERT(OnSocketThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(OnSocketThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(OnSocketThread()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("OnSocketThread()"
, "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp"
, 3124); AnnotateMozCrashReason("MOZ_ASSERT" "(" "OnSocketThread()"
")"); do { MOZ_CrashSequence(__null, 3124); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3125 if (!StaticPrefs::network_http_early_data_disable_on_error()) {
3126 return false;
3127 }
3128
3129 if (mExcluded0RttTcpOrigins.Count() >=
3130 StaticPrefs::network_http_early_data_max_error()) {
3131 return true;
3132 }
3133
3134 return mExcluded0RttTcpOrigins.Contains(ci->GetOrigin());
3135}
3136
3137bool nsHttpHandler::HttpActivityDistributorActivated() {
3138 if (!mActivityDistributor) {
3139 return false;
3140 }
3141
3142 return mActivityDistributor->Activated();
3143}
3144
3145void nsHttpHandler::ObserveHttpActivityWithArgs(
3146 const HttpActivityArgs& aArgs, uint32_t aActivityType,
3147 uint32_t aActivitySubtype, PRTime aTimestamp, uint64_t aExtraSizeData,
3148 const nsACString& aExtraStringData) {
3149 if (!HttpActivityDistributorActivated()) {
3150 return;
3151 }
3152
3153 if (aActivitySubtype == NS_HTTP_ACTIVITY_SUBTYPE_PROXY_RESPONSE_HEADERnsIHttpActivityObserver::ACTIVITY_SUBTYPE_PROXY_RESPONSE_HEADER &&
3154 !mActivityDistributor->ObserveProxyResponseEnabled()) {
3155 return;
3156 }
3157
3158 if (aActivityType == NS_ACTIVITY_TYPE_HTTP_CONNECTIONnsIHttpActivityObserver::ACTIVITY_TYPE_HTTP_CONNECTION &&
3159 !mActivityDistributor->ObserveConnectionEnabled()) {
3160 return;
3161 }
3162
3163 (void)mActivityDistributor->ObserveActivityWithArgs(
3164 aArgs, aActivityType, aActivitySubtype, aTimestamp, aExtraSizeData,
3165 aExtraStringData);
3166}
3167
3168} // namespace mozilla::net