| File: | root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp |
| Warning: | line 818, column 5 Value stored to 'rv' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 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 | |
| 142 | using mozilla::dom::Promise; |
| 143 | |
| 144 | namespace mozilla::net { |
| 145 | |
| 146 | LazyLogModule gHttpLog("nsHttp"); |
| 147 | LazyLogModule gHttpIOLog("HttpIO"); |
| 148 | |
| 149 | #ifdef ANDROID |
| 150 | static 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 |
| 174 | static 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 | |
| 196 | StaticRefPtr<nsHttpHandler> gHttpHandler; |
| 197 | |
| 198 | /* static */ |
| 199 | already_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. |
| 221 | static 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 | |
| 241 | static 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 | |
| 265 | Atomic<bool, Relaxed> nsHttpHandler::sParentalControlsEnabled(false); |
| 266 | |
| 267 | nsHttpHandler::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 | |
| 302 | nsHttpHandler::~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 | |
| 313 | void 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 | |
| 325 | static 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 | |
| 341 | nsresult 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 | mAltSvcMappingTemptativeMap.InsertOrUpdate( |
| 429 | host, MakeUnique<nsCString>(nsPrintfCString("h3=:%d", port))); |
| 430 | } |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | // monitor some preference changes |
| 435 | Preferences::RegisterPrefixCallbacks(nsHttpHandler::PrefsChanged, |
| 436 | gCallbackPrefs, this); |
| 437 | PrefsChanged(nullptr); |
| 438 | |
| 439 | mCompatFirefox.AssignLiteral("Firefox/" MOZILLA_UAVERSION"157.0"); |
| 440 | |
| 441 | nsCOMPtr<nsIXULAppInfo> appInfo; |
| 442 | appInfo = mozilla::components::XULRuntime::Service(); |
| 443 | |
| 444 | mAppName.AssignLiteral(MOZ_APP_UA_NAME""); |
| 445 | if (mAppName.Length() == 0 && appInfo) { |
| 446 | // Try to get the UA name from appInfo, falling back to the name |
| 447 | appInfo->GetUAName(mAppName); |
| 448 | if (mAppName.Length() == 0) { |
| 449 | appInfo->GetName(mAppName); |
| 450 | } |
| 451 | appInfo->GetVersion(mAppVersion); |
| 452 | mAppName.StripChars(R"( ()<>@,;:\"/[]?={})"); |
| 453 | } else { |
| 454 | mAppVersion.AssignLiteral(MOZ_APP_UA_VERSION"157.0a1"); |
| 455 | } |
| 456 | |
| 457 | mMisc.AssignLiteral("rv:" MOZILLA_UAVERSION"157.0"); |
| 458 | |
| 459 | // Generate the spoofed User Agent for fingerprinting resistance. |
| 460 | nsRFPService::GetSpoofedUserAgent(mSpoofedUserAgent); |
| 461 | |
| 462 | mSessionStartTime = NowInSeconds()PRTimeToSeconds(PR_Now()); |
| 463 | mHandlerActive = true; |
| 464 | |
| 465 | rv = InitConnectionMgr(); |
| 466 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv; |
| 467 | |
| 468 | mAltSvcCache = MakeUnique<AltSvcCache>(); |
| 469 | |
| 470 | mRequestContextService = RequestContextService::GetOrCreate(); |
| 471 | |
| 472 | #if defined(ANDROID) || defined(XP_IOS) |
| 473 | mProductSub.AssignLiteral(MOZILLA_UAVERSION"157.0"); |
| 474 | #else |
| 475 | mProductSub.AssignLiteral(LEGACY_UA_GECKO_TRAIL"20100101"); |
| 476 | #endif |
| 477 | |
| 478 | #if DEBUG1 |
| 479 | // dump user agent prefs |
| 480 | 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); |
| 481 | 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); |
| 482 | 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); |
| 483 | 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); |
| 484 | 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); |
| 485 | 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); |
| 486 | 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); |
| 487 | 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); |
| 488 | 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); |
| 489 | 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); |
| 490 | 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); |
| 491 | #endif |
| 492 | |
| 493 | // Startup the http category |
| 494 | // Bring alive the objects in the http-protocol-startup category |
| 495 | NS_CreateServicesFromCategory( |
| 496 | NS_HTTP_STARTUP_CATEGORY"http-startup-category", |
| 497 | static_cast<nsISupports*>(static_cast<void*>(this)), |
| 498 | NS_HTTP_STARTUP_TOPIC"http-startup"); |
| 499 | |
| 500 | nsCOMPtr<nsIObserverService> obsService = |
| 501 | static_cast<nsIObserverService*>(gIOService); |
| 502 | if (obsService) { |
| 503 | // register the handler object as a weak callback as we don't need to worry |
| 504 | // about shutdown ordering. |
| 505 | obsService->AddObserver(this, "profile-change-net-teardown", true); |
| 506 | obsService->AddObserver(this, "profile-change-net-restore", 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 | |
| 545 | void 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 | |
| 582 | void 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 | |
| 607 | const nsCString& nsHttpHandler::Http3QlogDir() { |
| 608 | if (StaticPrefs::network_http_http3_enable_qlog()) { |
| 609 | return mHttp3QlogDir; |
| 610 | } |
| 611 | |
| 612 | return EmptyCString(); |
| 613 | } |
| 614 | |
| 615 | void 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 | |
| 630 | nsresult 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. |
| 674 | nsresult 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 | mDictionaryCache->GetDictionaryFor( |
| 690 | aURI, aType, aChan, aSuspend, |
| 691 | [self = RefPtr(this), aRequest, aCallback]( |
| 692 | bool aNeedsResume, DictionaryCacheEntry* aDict) { |
| 693 | if (!aDict) { |
| 694 | // Accept-Encoding was already set in AddStandardHeaders |
| 695 | (aCallback)(aNeedsResume, nullptr); |
| 696 | return NS_OK; |
| 697 | } |
| 698 | |
| 699 | nsAutoCStringN<64> encodedHash = ":"_ns + aDict->GetHash() + ":"_ns; |
| 700 | |
| 701 | // We want to make sure that the cache entry doesn't disappear out |
| 702 | // from under us if we set the header, so do the callback to |
| 703 | // Prefetch() the entry before adding the headers (so we don't |
| 704 | // have to remove the headers if Prefetch() fails). It might fail |
| 705 | // if something is asynchronously Dooming the entry but the |
| 706 | // DictionaryCache hasn't been updated to remove the entry yet (or |
| 707 | // any other thing that were to desynchronize the DictionaryCache |
| 708 | // with the actual cache. |
| 709 | if ((aCallback)(aNeedsResume, aDict)) { |
| 710 | 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) |
| 711 | ("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); |
| 712 | // Need to retain access to the dictionary until the request |
| 713 | // completes. Note that this includes if the dictionary we offered |
| 714 | // gets replaced by another request while we're waiting for a |
| 715 | // response; in that case we need to read in a copy of the |
| 716 | // dictionary into memory before overwriting it and store in dict |
| 717 | // temporarily. |
| 718 | aRequest->SetDictionary(aDict); |
| 719 | |
| 720 | nsresult rv = aRequest->SetHeader( |
| 721 | nsHttp::Available_Dictionary, encodedHash, false, |
| 722 | nsHttpHeaderArray::eVarietyRequestOverride); |
| 723 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 724 | return rv; |
| 725 | } |
| 726 | if (!aDict->GetId().IsEmpty()) { |
| 727 | nsPrintfCString id("\"%s\"", aDict->GetId().get()); |
| 728 | 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); |
| 729 | rv = aRequest->SetHeader( |
| 730 | nsHttp::Dictionary_Id, id, false, |
| 731 | nsHttpHeaderArray::eVarietyRequestOverride); |
| 732 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 733 | return rv; |
| 734 | } |
| 735 | } |
| 736 | return aRequest->SetHeader( |
| 737 | nsHttp::Accept_Encoding, self->mDictionaryAcceptEncodings, |
| 738 | false, nsHttpHeaderArray::eVarietyRequestOverride); |
| 739 | } // else probably Prefetch failed |
| 740 | return NS_OK; |
| 741 | }); |
| 742 | } |
| 743 | } |
| 744 | // guard may call aCallback here |
| 745 | return rv; |
| 746 | } |
| 747 | |
| 748 | nsresult nsHttpHandler::AddStandardRequestHeaders( |
| 749 | nsHttpRequestHead* request, nsIURI* aURI, bool aIsHTTPS, |
| 750 | ExtContentPolicyType aContentPolicyType, bool aShouldResistFingerprinting, |
| 751 | const nsCString& aLanguageOverride) { |
| 752 | nsresult rv; |
| 753 | |
| 754 | // Add the "User-Agent" header |
| 755 | rv = request->SetHeader(nsHttp::User_Agent, |
| 756 | UserAgent(aShouldResistFingerprinting), false, |
| 757 | nsHttpHeaderArray::eVarietyRequestDefault); |
| 758 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv; |
| 759 | |
| 760 | // MIME based content negotiation lives! |
| 761 | // Add the "Accept" header. Note, this is set as an override because the |
| 762 | // service worker expects to see it. The other "default" headers are |
| 763 | // hidden from service worker interception. |
| 764 | nsAutoCString accept; |
| 765 | if (aContentPolicyType == ExtContentPolicy::TYPE_DOCUMENT || |
| 766 | aContentPolicyType == ExtContentPolicy::TYPE_SUBDOCUMENT) { |
| 767 | accept.Assign(mDocumentAcceptHeader); |
| 768 | } else if (aContentPolicyType == ExtContentPolicy::TYPE_IMAGE || |
| 769 | aContentPolicyType == ExtContentPolicy::TYPE_IMAGESET) { |
| 770 | accept.Assign(mImageAcceptHeader); |
| 771 | } else if (aContentPolicyType == ExtContentPolicy::TYPE_STYLESHEET) { |
| 772 | accept.Assign(ACCEPT_HEADER_STYLE"text/css,*/*;q=0.1"); |
| 773 | } else if (aContentPolicyType == ExtContentPolicy::TYPE_JSON) { |
| 774 | accept.Assign(ACCEPT_HEADER_JSON"application/json,*/*;q=0.5"); |
| 775 | } else if (aContentPolicyType == ExtContentPolicy::TYPE_TEXT) { |
| 776 | accept.Assign(ACCEPT_HEADER_TEXT"text/plain,*/*;q=0.5"); |
| 777 | } else { |
| 778 | accept.Assign(ACCEPT_HEADER_ALL"*/*"); |
| 779 | } |
| 780 | |
| 781 | rv = request->SetHeader(nsHttp::Accept, accept, false, |
| 782 | nsHttpHeaderArray::eVarietyRequestOverride); |
| 783 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv; |
| 784 | |
| 785 | if (!aLanguageOverride.IsEmpty()) { |
| 786 | nsAutoCString acceptLanguage; |
| 787 | acceptLanguage.Assign(aLanguageOverride.get()); |
| 788 | rv = request->SetHeader(nsHttp::Accept_Language, acceptLanguage, false, |
| 789 | nsHttpHeaderArray::eVarietyRequestOverride); |
| 790 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv; |
| 791 | } else { |
| 792 | // Add the "Accept-Language" header. This header is also exposed to the |
| 793 | // service worker. |
| 794 | if (mAcceptLanguagesIsDirty) { |
| 795 | rv = SetAcceptLanguages(); |
| 796 | 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" , 796); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))" ")"); do { MOZ_CrashSequence(__null, 796); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 797 | } |
| 798 | |
| 799 | // Add the "Accept-Language" header |
| 800 | if (!mAcceptLanguages.IsEmpty()) { |
| 801 | rv = request->SetHeader(nsHttp::Accept_Language, mAcceptLanguages, false, |
| 802 | nsHttpHeaderArray::eVarietyRequestOverride); |
| 803 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv; |
| 804 | } |
| 805 | } |
| 806 | |
| 807 | // add the "Send Hint" header |
| 808 | if (mSafeHintEnabled || sParentalControlsEnabled) { |
| 809 | rv = request->SetHeader(nsHttp::Prefer, "safe"_ns, false, |
| 810 | nsHttpHeaderArray::eVarietyRequestDefault); |
| 811 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv; |
| 812 | } |
| 813 | |
| 814 | if (aIsHTTPS) { |
| 815 | rv = request->SetHeader(nsHttp::Accept_Encoding, mHttpsAcceptEncodings, |
| 816 | false, nsHttpHeaderArray::eVarietyRequestDefault); |
| 817 | } else { |
| 818 | rv = request->SetHeader(nsHttp::Accept_Encoding, mHttpAcceptEncodings, |
Value stored to 'rv' is never read | |
| 819 | false, nsHttpHeaderArray::eVarietyRequestDefault); |
| 820 | } |
| 821 | return NS_OK; |
| 822 | } |
| 823 | |
| 824 | nsresult nsHttpHandler::AddConnectionHeader(nsHttpRequestHead* request, |
| 825 | uint32_t caps) { |
| 826 | // RFC2616 section 19.6.2 states that the "Connection: keep-alive" |
| 827 | // and "Keep-alive" request headers should not be sent by HTTP/1.1 |
| 828 | // user-agents. But this is not a problem in practice, and the |
| 829 | // alternative proxy-connection is worse. see 570283 |
| 830 | |
| 831 | constexpr auto close = "close"_ns; |
| 832 | constexpr auto keepAlive = "keep-alive"_ns; |
| 833 | |
| 834 | const nsLiteralCString* connectionType = &close; |
| 835 | if (caps & NS_HTTP_ALLOW_KEEPALIVE(1 << 0)) { |
| 836 | connectionType = &keepAlive; |
| 837 | } |
| 838 | |
| 839 | return request->SetHeader(nsHttp::Connection, *connectionType); |
| 840 | } |
| 841 | |
| 842 | bool nsHttpHandler::IsAcceptableEncoding(const char* enc, bool isSecure) { |
| 843 | if (!enc) return false; |
| 844 | |
| 845 | // we used to accept x-foo anytime foo was acceptable, but that's just |
| 846 | // continuing bad behavior.. so limit it to known x-* patterns |
| 847 | bool rv; |
| 848 | if (isSecure) { |
| 849 | // Should be a superset of mAcceptEncodings (unless someone messes with |
| 850 | // prefs) |
| 851 | rv = nsHttp::FindToken(mDictionaryAcceptEncodings.get(), enc, |
| 852 | HTTP_LWS" \t" ",") != nullptr; |
| 853 | } else { |
| 854 | rv = nsHttp::FindToken(mHttpAcceptEncodings.get(), enc, HTTP_LWS" \t" ",") != |
| 855 | nullptr; |
| 856 | } |
| 857 | // gzip and deflate are inherently acceptable in modern HTTP - always |
| 858 | // process them if a stream converter can also be found. |
| 859 | if (!rv && |
| 860 | (!nsCRT::strcasecmp(enc, "gzip") || !nsCRT::strcasecmp(enc, "deflate") || |
| 861 | !nsCRT::strcasecmp(enc, "x-gzip") || |
| 862 | !nsCRT::strcasecmp(enc, "x-deflate"))) { |
| 863 | rv = true; |
| 864 | } |
| 865 | 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) |
| 866 | 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); |
| 867 | return rv; |
| 868 | } |
| 869 | |
| 870 | nsISiteIntegrityService* nsHttpHandler::GetSiteIntegrityService() { |
| 871 | if (!mSiteIntegrityService) { |
| 872 | nsCOMPtr<nsISiteIntegrityService> service; |
| 873 | service = mozilla::components::SiteIntegrity::Service(); |
| 874 | mSiteIntegrityService = new nsMainThreadPtrHolder<nsISiteIntegrityService>( |
| 875 | "nsHttpHandler::mSiteIntegrityService", service); |
| 876 | } |
| 877 | return mSiteIntegrityService; |
| 878 | } |
| 879 | |
| 880 | nsISiteSecurityService* nsHttpHandler::GetSSService() { |
| 881 | if (!mSSService) { |
| 882 | nsCOMPtr<nsISiteSecurityService> service; |
| 883 | service = mozilla::components::SiteSecurity::Service(); |
| 884 | mSSService = new nsMainThreadPtrHolder<nsISiteSecurityService>( |
| 885 | "nsHttpHandler::mSSService", service); |
| 886 | } |
| 887 | return mSSService; |
| 888 | } |
| 889 | |
| 890 | nsICookieService* nsHttpHandler::GetCookieService() { |
| 891 | if (!mCookieService) { |
| 892 | nsCOMPtr<nsICookieService> service = |
| 893 | do_GetService(NS_COOKIESERVICE_CONTRACTID"@mozilla.org/cookieService;1"); |
| 894 | mCookieService = new nsMainThreadPtrHolder<nsICookieService>( |
| 895 | "nsHttpHandler::mCookieService", service); |
| 896 | } |
| 897 | return mCookieService; |
| 898 | } |
| 899 | |
| 900 | nsresult nsHttpHandler::GetIOService(nsIIOService** result) { |
| 901 | 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" , 901); return NS_ERROR_INVALID_POINTER; } } while (false); |
| 902 | |
| 903 | *result = do_AddRef(mIOService.get()).take(); |
| 904 | return NS_OK; |
| 905 | } |
| 906 | |
| 907 | void nsHttpHandler::NotifyObservers(nsIChannel* chan, const char* event) { |
| 908 | 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) |
| 909 | 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); |
| 910 | nsCOMPtr<nsIObserverService> obsService = services::GetObserverService(); |
| 911 | if (obsService) obsService->NotifyObservers(chan, event, nullptr); |
| 912 | } |
| 913 | |
| 914 | nsresult nsHttpHandler::AsyncOnChannelRedirect( |
| 915 | nsIChannel* oldChan, nsIChannel* newChan, uint32_t flags, |
| 916 | nsIEventTarget* mainThreadEventTarget) { |
| 917 | 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" , 917); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread() && (oldChan && newChan)" ")"); do { MOZ_CrashSequence(__null, 917); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 918 | |
| 919 | nsCOMPtr<nsIURI> oldURI; |
| 920 | oldChan->GetURI(getter_AddRefs(oldURI)); |
| 921 | 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" , 921); AnnotateMozCrashReason("MOZ_ASSERT" "(" "oldURI" ")") ; do { MOZ_CrashSequence(__null, 921); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 922 | |
| 923 | nsCOMPtr<nsIURI> newURI; |
| 924 | newChan->GetURI(getter_AddRefs(newURI)); |
| 925 | 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" , 925); AnnotateMozCrashReason("MOZ_ASSERT" "(" "newURI" ")") ; do { MOZ_CrashSequence(__null, 925); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 926 | |
| 927 | PrepareForAntiTrackingRedirectHeuristic(oldChan, oldURI, newChan, newURI); |
| 928 | |
| 929 | DynamicFpiRedirectHeuristic(oldChan, oldURI, newChan, newURI); |
| 930 | |
| 931 | // TODO E10S This helper has to be initialized on the other process |
| 932 | RefPtr<nsAsyncRedirectVerifyHelper> redirectCallbackHelper = |
| 933 | new nsAsyncRedirectVerifyHelper(); |
| 934 | |
| 935 | return redirectCallbackHelper->Init(oldChan, newChan, flags, |
| 936 | mainThreadEventTarget); |
| 937 | } |
| 938 | |
| 939 | /* static */ |
| 940 | nsresult nsHttpHandler::GenerateHostPort(const nsCString& host, int32_t port, |
| 941 | nsACString& hostLine) { |
| 942 | return NS_GenerateHostPort(host, port, hostLine); |
| 943 | } |
| 944 | |
| 945 | // static |
| 946 | uint8_t nsHttpHandler::UrgencyFromCoSFlags(uint32_t cos, |
| 947 | int32_t aSupportsPriority) { |
| 948 | uint8_t urgency; |
| 949 | if (cos & nsIClassOfService::UrgentStart) { |
| 950 | // coming from an user interaction => response should be the highest |
| 951 | // priority |
| 952 | urgency = 1; |
| 953 | } else if (cos & nsIClassOfService::Leader) { |
| 954 | // main html document normal priority |
| 955 | urgency = 2; |
| 956 | } else if (cos & nsIClassOfService::Unblocked) { |
| 957 | urgency = 3; |
| 958 | } else if (cos & nsIClassOfService::Follower) { |
| 959 | urgency = 4; |
| 960 | } else if (cos & nsIClassOfService::Speculative) { |
| 961 | urgency = 6; |
| 962 | } else if (cos & nsIClassOfService::Background) { |
| 963 | // background tasks can be deprioritzed to the lowest priority |
| 964 | urgency = 6; |
| 965 | } else if (cos & nsIClassOfService::Tail) { |
| 966 | urgency = mozilla::StaticPrefs::network_http_tailing_urgency(); |
| 967 | } else { |
| 968 | // all others get a lower priority than the main html document |
| 969 | urgency = 4; |
| 970 | } |
| 971 | |
| 972 | int8_t adjustment = 0; |
| 973 | if (mozilla::StaticPrefs::network_fetchpriority_adjust_urgency()) { |
| 974 | if (aSupportsPriority <= nsISupportsPriority::PRIORITY_HIGHEST) { |
| 975 | adjustment = -2; |
| 976 | } else if (aSupportsPriority <= nsISupportsPriority::PRIORITY_HIGH) { |
| 977 | adjustment = -1; |
| 978 | } else if (aSupportsPriority >= nsISupportsPriority::PRIORITY_LOWEST) { |
| 979 | adjustment = 2; |
| 980 | } else if (aSupportsPriority >= nsISupportsPriority::PRIORITY_LOW) { |
| 981 | adjustment = 1; |
| 982 | } |
| 983 | } |
| 984 | |
| 985 | auto adjustUrgency = [](uint8_t u, int8_t a) -> uint8_t { |
| 986 | int16_t result = static_cast<int16_t>(u) + a; |
| 987 | if (result <= 0) { |
| 988 | return 0; |
| 989 | } |
| 990 | if (result >= 6) { |
| 991 | return 6; |
| 992 | } |
| 993 | return result; |
| 994 | }; |
| 995 | |
| 996 | return adjustUrgency(urgency, adjustment); |
| 997 | } |
| 998 | |
| 999 | //----------------------------------------------------------------------------- |
| 1000 | // nsHttpHandler <private> |
| 1001 | //----------------------------------------------------------------------------- |
| 1002 | |
| 1003 | const nsCString& nsHttpHandler::UserAgent(bool aShouldResistFingerprinting) { |
| 1004 | if (aShouldResistFingerprinting && !mSpoofedUserAgent.IsEmpty()) { |
| 1005 | 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); |
| 1006 | return mSpoofedUserAgent; |
| 1007 | } |
| 1008 | |
| 1009 | if (!mUserAgentOverride.IsVoid()) { |
| 1010 | 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); |
| 1011 | return mUserAgentOverride; |
| 1012 | } |
| 1013 | |
| 1014 | if (mUserAgentIsDirty) { |
| 1015 | BuildUserAgent(); |
| 1016 | mUserAgentIsDirty = false; |
| 1017 | } |
| 1018 | |
| 1019 | return mUserAgent; |
| 1020 | } |
| 1021 | |
| 1022 | void nsHttpHandler::BuildUserAgent() { |
| 1023 | 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); |
| 1024 | |
| 1025 | 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" , 1026); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mLegacyAppName.IsEmpty() && !mLegacyAppVersion.IsEmpty()" ") (" "HTTP cannot send practical requests without this much" ")"); do { MOZ_CrashSequence(__null, 1026); __attribute__((nomerge )) ::abort(); } while (false); } } while (false) |
| 1026 | "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" , 1026); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mLegacyAppName.IsEmpty() && !mLegacyAppVersion.IsEmpty()" ") (" "HTTP cannot send practical requests without this much" ")"); do { MOZ_CrashSequence(__null, 1026); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 1027 | |
| 1028 | // preallocate to worst-case size, which should always be better |
| 1029 | // than if we didn't preallocate at all. |
| 1030 | mUserAgent.SetCapacity(mLegacyAppName.Length() + mLegacyAppVersion.Length() + |
| 1031 | #ifndef UA_SPARE_PLATFORM |
| 1032 | mPlatform.Length() + |
| 1033 | #endif |
| 1034 | mOscpu.Length() + mMisc.Length() + mProduct.Length() + |
| 1035 | mProductSub.Length() + mAppName.Length() + |
| 1036 | mAppVersion.Length() + mCompatFirefox.Length() + |
| 1037 | mCompatDevice.Length() + mDeviceModelId.Length() + 13); |
| 1038 | |
| 1039 | // Application portion |
| 1040 | mUserAgent.Assign(mLegacyAppName); |
| 1041 | mUserAgent += '/'; |
| 1042 | mUserAgent += mLegacyAppVersion; |
| 1043 | mUserAgent += ' '; |
| 1044 | |
| 1045 | // Application comment |
| 1046 | mUserAgent += '('; |
| 1047 | #ifndef UA_SPARE_PLATFORM |
| 1048 | if (!mPlatform.IsEmpty()) { |
| 1049 | mUserAgent += mPlatform; |
| 1050 | mUserAgent.AppendLiteral("; "); |
| 1051 | } |
| 1052 | #endif |
| 1053 | if (!mCompatDevice.IsEmpty()) { |
| 1054 | mUserAgent += mCompatDevice; |
| 1055 | mUserAgent.AppendLiteral("; "); |
| 1056 | } else if (!mOscpu.IsEmpty()) { |
| 1057 | mUserAgent += mOscpu; |
| 1058 | mUserAgent.AppendLiteral("; "); |
| 1059 | } |
| 1060 | if (!mDeviceModelId.IsEmpty()) { |
| 1061 | mUserAgent += mDeviceModelId; |
| 1062 | mUserAgent.AppendLiteral("; "); |
| 1063 | } |
| 1064 | mUserAgent += mMisc; |
| 1065 | mUserAgent += ')'; |
| 1066 | |
| 1067 | // Product portion |
| 1068 | mUserAgent += ' '; |
| 1069 | mUserAgent += mProduct; |
| 1070 | mUserAgent += '/'; |
| 1071 | mUserAgent += mProductSub; |
| 1072 | |
| 1073 | bool isFirefox = mAppName.EqualsLiteral("Firefox"); |
| 1074 | if (isFirefox || mCompatFirefoxEnabled) { |
| 1075 | // "Firefox/x.y" (compatibility) app token |
| 1076 | mUserAgent += ' '; |
| 1077 | mUserAgent += mCompatFirefox; |
| 1078 | } |
| 1079 | if (!isFirefox) { |
| 1080 | // App portion |
| 1081 | mUserAgent += ' '; |
| 1082 | mUserAgent += mAppName; |
| 1083 | mUserAgent += '/'; |
| 1084 | mUserAgent += mAppVersion; |
| 1085 | } |
| 1086 | } |
| 1087 | |
| 1088 | #ifdef XP_WIN |
| 1089 | // Hardcode the reported Windows version to 10.0. This way, Microsoft doesn't |
| 1090 | // get to change Web compat-sensitive values without our veto. The compat- |
| 1091 | // sensitivity keeps going up as 10.0 stays as the current value for longer |
| 1092 | // and longer. If the system-reported version ever changes, we'll be able to |
| 1093 | // take our time to evaluate the Web compat impact instead of having to |
| 1094 | // scramble to react like happened with macOS changing from 10.x to 11.x. |
| 1095 | # define OSCPU_WINDOWS "Windows NT 10.0" |
| 1096 | # define OSCPU_WIN64 OSCPU_WINDOWS "; Win64; x64" |
| 1097 | #endif |
| 1098 | |
| 1099 | void nsHttpHandler::InitUserAgentComponents() { |
| 1100 | // Don't build user agent components in socket process, since the system info |
| 1101 | // is not available. |
| 1102 | if (XRE_IsSocketProcess()) { |
| 1103 | mUserAgentIsDirty = true; |
| 1104 | return; |
| 1105 | } |
| 1106 | |
| 1107 | // Gather platform. |
| 1108 | mPlatform.AssignLiteral( |
| 1109 | #if defined(ANDROID) |
| 1110 | "Android" |
| 1111 | #elif defined(XP_WIN) |
| 1112 | "Windows" |
| 1113 | #elif defined(XP_MACOSX) |
| 1114 | "Macintosh" |
| 1115 | #elif defined(XP_IOS) |
| 1116 | "iPhone" |
| 1117 | #elif defined(XP_UNIX1) |
| 1118 | // We historically have always had X11 here, |
| 1119 | // and there seems little a webpage can sensibly do |
| 1120 | // based on it being something else, so use X11 for |
| 1121 | // backwards compatibility in all cases. |
| 1122 | "X11" |
| 1123 | #endif |
| 1124 | ); |
| 1125 | |
| 1126 | #ifdef XP_UNIX1 |
| 1127 | if (IsRunningUnderUbuntuSnap()) { |
| 1128 | mPlatform.AppendLiteral("; Ubuntu"); |
| 1129 | } |
| 1130 | #endif |
| 1131 | |
| 1132 | #ifdef ANDROID |
| 1133 | nsCOMPtr<nsIPropertyBag2> infoService; |
| 1134 | infoService = mozilla::components::SystemInfo::Service(); |
| 1135 | 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" , 1135); AnnotateMozCrashReason("MOZ_ASSERT" "(" "infoService" ") (" "Could not find a system info service" ")"); do { MOZ_CrashSequence (__null, 1135); __attribute__((nomerge)) ::abort(); } while ( false); } } while (false); |
| 1136 | nsresult rv; |
| 1137 | |
| 1138 | // Add the Android version number to the Fennec platform identifier. |
| 1139 | nsAutoString androidVersion; |
| 1140 | rv = infoService->GetPropertyAsAString(u"release_version"_ns, androidVersion); |
| 1141 | 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" , 1147); 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, 1147); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); } } while ( false) |
| 1142 | 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" , 1147); 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, 1147); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); } } while ( false) |
| 1143 | // 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" , 1147); 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, 1147); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); } } while ( false) |
| 1144 | (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" , 1147); 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, 1147); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); } } while ( false) |
| 1145 | // 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" , 1147); 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, 1147); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); } } while ( false) |
| 1146 | (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" , 1147); 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, 1147); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); } } while ( false) |
| 1147 | (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" , 1147); 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, 1147); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); } } while ( false); |
| 1148 | |
| 1149 | // Normalize: strip any minor-version suffix (everything from the first '.' |
| 1150 | // onward, including the '.'). Some OEM firmwares report Build.VERSION.RELEASE |
| 1151 | // as e.g. "14.0" while stock AOSP reports "14"; that variance splits the |
| 1152 | // population into fingerprintable subsets without conveying any useful |
| 1153 | // information about the OS. Bug 2043395. |
| 1154 | int32_t dotIdx = androidVersion.FindChar(u'.'); |
| 1155 | if (dotIdx >= 0) { |
| 1156 | androidVersion.Truncate(dotIdx); |
| 1157 | } |
| 1158 | |
| 1159 | // Spoof version "Android 10" for Android OS versions < 10 to reduce their |
| 1160 | // fingerprintable user information. For Android OS versions >= 10, report |
| 1161 | // the real OS version because some enterprise websites only want to permit |
| 1162 | // clients with recent OS version (like bug 1876742). After the truncation |
| 1163 | // above, all versions are bare integers; two digits means the version is |
| 1164 | // >= 10. |
| 1165 | mPlatform += " "; |
| 1166 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && androidVersion.Length() >= 2 && |
| 1167 | std::isdigit(androidVersion[0]) && std::isdigit(androidVersion[1])) { |
| 1168 | mPlatform += NS_LossyConvertUTF16toASCII(androidVersion); |
| 1169 | } else { |
| 1170 | mPlatform.AppendLiteral("10"); |
| 1171 | } |
| 1172 | |
| 1173 | // Add the `Mobile` or `TV` token when running on device. |
| 1174 | bool isTV; |
| 1175 | rv = infoService->GetPropertyAsBool(u"tv"_ns, &isTV); |
| 1176 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && isTV) { |
| 1177 | mCompatDevice.AssignLiteral("TV"); |
| 1178 | } else { |
| 1179 | mCompatDevice.AssignLiteral("Mobile"); |
| 1180 | } |
| 1181 | |
| 1182 | if (Preferences::GetBool(UA_PREF("use_device")"general.useragent." "use_device", false)) { |
| 1183 | mDeviceModelId = mozilla::net::GetDeviceModelId(); |
| 1184 | } |
| 1185 | #endif // ANDROID |
| 1186 | |
| 1187 | #if defined(XP_IOS) |
| 1188 | // Freeze the iOS version to 18.0, use an underscore separator to avoid |
| 1189 | // detection as macOS. |
| 1190 | mCompatDevice.AssignLiteral("CPU iPhone OS 18_0 like Mac OS X"); |
| 1191 | #endif |
| 1192 | |
| 1193 | // Gather OS/CPU. |
| 1194 | #if defined(XP_WIN) |
| 1195 | |
| 1196 | # if defined _M_X64 || defined _M_AMD64 |
| 1197 | mOscpu.AssignLiteral(OSCPU_WIN64); |
| 1198 | # elif defined(_ARM64_) |
| 1199 | // Report ARM64 Windows 11+ as x86_64 and Windows 10 as x86. Windows 11+ |
| 1200 | // supports x86_64 emulation, but Windows 10 only supports x86 emulation. |
| 1201 | if (IsWin11OrLater()) { |
| 1202 | mOscpu.AssignLiteral(OSCPU_WIN64); |
| 1203 | } else { |
| 1204 | mOscpu.AssignLiteral(OSCPU_WINDOWS); |
| 1205 | } |
| 1206 | # else |
| 1207 | BOOL isWow64 = FALSE; |
| 1208 | if (!IsWow64Process(GetCurrentProcess(), &isWow64)) { |
| 1209 | isWow64 = FALSE; |
| 1210 | } |
| 1211 | if (isWow64) { |
| 1212 | mOscpu.AssignLiteral(OSCPU_WIN64); |
| 1213 | } else { |
| 1214 | mOscpu.AssignLiteral(OSCPU_WINDOWS); |
| 1215 | } |
| 1216 | # endif |
| 1217 | |
| 1218 | #elif defined(XP_MACOSX) |
| 1219 | mOscpu.AssignLiteral("Intel Mac OS X 10.15"); |
| 1220 | #elif defined(ANDROID) |
| 1221 | mOscpu.AssignLiteral("Linux armv81"); |
| 1222 | #elif defined(XP_IOS) |
| 1223 | mOscpu.AssignLiteral("iPhone"); |
| 1224 | #else |
| 1225 | mOscpu.AssignLiteral("Linux x86_64"); |
| 1226 | #endif |
| 1227 | |
| 1228 | mUserAgentIsDirty = true; |
| 1229 | } |
| 1230 | |
| 1231 | #ifdef XP_MACOSX |
| 1232 | void nsHttpHandler::InitMSAuthorities() { |
| 1233 | if (!StaticPrefs::network_http_microsoft_entra_sso_enabled()) { |
| 1234 | return; |
| 1235 | } |
| 1236 | |
| 1237 | nsAutoCString authorityList; |
| 1238 | |
| 1239 | 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) )) |
| 1240 | authorityList))((bool)(__builtin_expect(!!(NS_FAILED_impl(Preferences::GetCString ("network.microsoft-sso-authority-list", authorityList))), 0) ))) { |
| 1241 | return; |
| 1242 | } |
| 1243 | mMSAuthorities.Clear(); |
| 1244 | |
| 1245 | // Normalize the MS authority list |
| 1246 | nsCCharSeparatedTokenizer tokenizer(authorityList, ','); |
| 1247 | while (tokenizer.hasMoreTokens()) { |
| 1248 | const nsDependentCSubstring& token = tokenizer.nextToken(); |
| 1249 | mMSAuthorities.Insert(token); |
| 1250 | } |
| 1251 | } |
| 1252 | #endif |
| 1253 | |
| 1254 | uint32_t nsHttpHandler::MaxSocketCount() { |
| 1255 | PR_CallOnce(&nsSocketTransportService::gMaxCountInitOnce, |
| 1256 | nsSocketTransportService::DiscoverMaxCount); |
| 1257 | // Don't use the full max count because sockets can be held in |
| 1258 | // the persistent connection pool for a long time and that could |
| 1259 | // starve other users. |
| 1260 | |
| 1261 | uint32_t maxCount = nsSocketTransportService::gMaxCount; |
| 1262 | if (maxCount <= 8) { |
| 1263 | maxCount = 1; |
| 1264 | } else { |
| 1265 | maxCount -= 8; |
| 1266 | } |
| 1267 | |
| 1268 | return maxCount; |
| 1269 | } |
| 1270 | |
| 1271 | // static |
| 1272 | void nsHttpHandler::PrefsChanged(const char* pref, void* self) { |
| 1273 | static_cast<nsHttpHandler*>(self)->PrefsChanged(pref); |
| 1274 | } |
| 1275 | |
| 1276 | void nsHttpHandler::PrefsChanged(const char* pref) { |
| 1277 | nsresult rv = NS_OK; |
| 1278 | int32_t val; |
| 1279 | |
| 1280 | 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); |
| 1281 | |
| 1282 | if (pref) { |
| 1283 | gIOService->NotifySocketProcessPrefsChanged(pref); |
| 1284 | } |
| 1285 | |
| 1286 | #define PREF_CHANGED(p) ((pref == nullptr) || !strcmp(pref, p)) |
| 1287 | #define MULTI_PREF_CHANGED(p) \ |
| 1288 | ((pref == nullptr) || !strncmp(pref, p, sizeof(p) - 1)) |
| 1289 | |
| 1290 | // If a security pref changed, lets clear our connection pool reuse |
| 1291 | if (MULTI_PREF_CHANGED(SECURITY_PREFIX"security.")) { |
| 1292 | 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); |
| 1293 | if (mConnMgr) { |
| 1294 | rv = mConnMgr->DoShiftReloadConnectionCleanup(); |
| 1295 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 1296 | 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) |
| 1297 | ("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) |
| 1298 | "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) |
| 1299 | 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); |
| 1300 | } |
| 1301 | rv = mConnMgr->PruneDeadConnections(); |
| 1302 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 1303 | 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) |
| 1304 | ("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) |
| 1305 | "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) |
| 1306 | 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); |
| 1307 | } |
| 1308 | } |
| 1309 | } |
| 1310 | |
| 1311 | // |
| 1312 | // UA components |
| 1313 | // |
| 1314 | |
| 1315 | bool cVar = false; |
| 1316 | |
| 1317 | if (PREF_CHANGED(UA_PREF("compatMode.firefox")"general.useragent." "compatMode.firefox")) { |
| 1318 | rv = Preferences::GetBool(UA_PREF("compatMode.firefox")"general.useragent." "compatMode.firefox", &cVar); |
| 1319 | mCompatFirefoxEnabled = (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cVar); |
| 1320 | mUserAgentIsDirty = true; |
| 1321 | } |
| 1322 | |
| 1323 | // general.useragent.override |
| 1324 | if (PREF_CHANGED(UA_PREF("override")"general.useragent." "override")) { |
| 1325 | Preferences::GetCString(UA_PREF("override")"general.useragent." "override", mUserAgentOverride); |
| 1326 | mUserAgentIsDirty = true; |
| 1327 | } |
| 1328 | |
| 1329 | #ifdef ANDROID |
| 1330 | // general.useragent.use_device |
| 1331 | if (PREF_CHANGED(UA_PREF("use_device")"general.useragent." "use_device")) { |
| 1332 | if (Preferences::GetBool(UA_PREF("use_device")"general.useragent." "use_device", false)) { |
| 1333 | if (!XRE_IsSocketProcess()) { |
| 1334 | mDeviceModelId = mozilla::net::GetDeviceModelId(); |
| 1335 | if (gIOService->SocketProcessReady()) { |
| 1336 | RefPtr<SocketProcessParent> socketParent = |
| 1337 | SocketProcessParent::GetSingleton(); |
| 1338 | (void)socketParent->SendUpdateDeviceModelId(mDeviceModelId); |
| 1339 | } |
| 1340 | } |
| 1341 | } else { |
| 1342 | mDeviceModelId.Truncate(); |
| 1343 | } |
| 1344 | mUserAgentIsDirty = true; |
| 1345 | } |
| 1346 | #endif |
| 1347 | |
| 1348 | // |
| 1349 | // HTTP options |
| 1350 | // |
| 1351 | |
| 1352 | if (PREF_CHANGED(HTTP_PREF("keep-alive.timeout")"network.http." "keep-alive.timeout")) { |
| 1353 | rv = Preferences::GetInt(HTTP_PREF("keep-alive.timeout")"network.http." "keep-alive.timeout", &val); |
| 1354 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1355 | mIdleTimeout = PR_SecondsToInterval(std::clamp(val, 1, 0xffff)); |
| 1356 | } |
| 1357 | } |
| 1358 | |
| 1359 | if (PREF_CHANGED(HTTP_PREF("request.max-attempts")"network.http." "request.max-attempts")) { |
| 1360 | rv = Preferences::GetInt(HTTP_PREF("request.max-attempts")"network.http." "request.max-attempts", &val); |
| 1361 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1362 | mMaxRequestAttempts = (uint16_t)std::clamp(val, 1, 0xffff); |
| 1363 | } |
| 1364 | } |
| 1365 | |
| 1366 | if (PREF_CHANGED(HTTP_PREF("request.max-start-delay")"network.http." "request.max-start-delay")) { |
| 1367 | rv = Preferences::GetInt(HTTP_PREF("request.max-start-delay")"network.http." "request.max-start-delay", &val); |
| 1368 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1369 | mMaxRequestDelay = (uint16_t)std::clamp(val, 0, 0xffff); |
| 1370 | if (mConnMgr) { |
| 1371 | rv = mConnMgr->UpdateParam(nsHttpConnectionMgr::MAX_REQUEST_DELAY, |
| 1372 | mMaxRequestDelay); |
| 1373 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 1374 | 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) |
| 1375 | ("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) |
| 1376 | "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) |
| 1377 | 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); |
| 1378 | } |
| 1379 | } |
| 1380 | } |
| 1381 | } |
| 1382 | |
| 1383 | if (PREF_CHANGED(HTTP_PREF("response.timeout")"network.http." "response.timeout")) { |
| 1384 | rv = Preferences::GetInt(HTTP_PREF("response.timeout")"network.http." "response.timeout", &val); |
| 1385 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1386 | mResponseTimeout = PR_SecondsToInterval(std::clamp(val, 0, 0xffff)); |
| 1387 | } |
| 1388 | } |
| 1389 | |
| 1390 | if (PREF_CHANGED(HTTP_PREF("network-changed.timeout")"network.http." "network-changed.timeout")) { |
| 1391 | rv = Preferences::GetInt(HTTP_PREF("network-changed.timeout")"network.http." "network-changed.timeout", &val); |
| 1392 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1393 | mNetworkChangedTimeout = std::clamp(val, 1, 600) * 1000; |
| 1394 | } |
| 1395 | } |
| 1396 | |
| 1397 | if (PREF_CHANGED(HTTP_PREF("max-connections")"network.http." "max-connections")) { |
| 1398 | rv = Preferences::GetInt(HTTP_PREF("max-connections")"network.http." "max-connections", &val); |
| 1399 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1400 | mMaxConnections = |
| 1401 | (uint16_t)std::clamp((uint32_t)val, (uint32_t)1, MaxSocketCount()); |
| 1402 | |
| 1403 | if (mConnMgr) { |
| 1404 | rv = mConnMgr->UpdateParam(nsHttpConnectionMgr::MAX_CONNECTIONS, |
| 1405 | mMaxConnections); |
| 1406 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 1407 | 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) |
| 1408 | ("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) |
| 1409 | "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) |
| 1410 | 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); |
| 1411 | } |
| 1412 | } |
| 1413 | } |
| 1414 | } |
| 1415 | |
| 1416 | if (PREF_CHANGED( |
| 1417 | HTTP_PREF("max-urgent-start-excessive-connections-per-host")"network.http." "max-urgent-start-excessive-connections-per-host")) { |
| 1418 | rv = Preferences::GetInt( |
| 1419 | HTTP_PREF("max-urgent-start-excessive-connections-per-host")"network.http." "max-urgent-start-excessive-connections-per-host", &val); |
| 1420 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1421 | mMaxUrgentExcessiveConns = (uint8_t)std::clamp(val, 1, 0xff); |
| 1422 | if (mConnMgr) { |
| 1423 | rv = mConnMgr->UpdateParam(nsHttpConnectionMgr::MAX_URGENT_START_Q, |
| 1424 | mMaxUrgentExcessiveConns); |
| 1425 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 1426 | 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) |
| 1427 | ("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) |
| 1428 | "(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) |
| 1429 | "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) |
| 1430 | 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); |
| 1431 | } |
| 1432 | } |
| 1433 | } |
| 1434 | } |
| 1435 | |
| 1436 | if (PREF_CHANGED(HTTP_PREF("max-persistent-connections-per-server")"network.http." "max-persistent-connections-per-server")) { |
| 1437 | rv = Preferences::GetInt(HTTP_PREF("max-persistent-connections-per-server")"network.http." "max-persistent-connections-per-server", |
| 1438 | &val); |
| 1439 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1440 | mMaxPersistentConnectionsPerServer = (uint8_t)std::clamp(val, 1, 0xff); |
| 1441 | if (mConnMgr) { |
| 1442 | rv = mConnMgr->UpdateParam( |
| 1443 | nsHttpConnectionMgr::MAX_PERSISTENT_CONNECTIONS_PER_HOST, |
| 1444 | mMaxPersistentConnectionsPerServer); |
| 1445 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 1446 | 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) |
| 1447 | ("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) |
| 1448 | "(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) |
| 1449 | "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) |
| 1450 | 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); |
| 1451 | } |
| 1452 | } |
| 1453 | } |
| 1454 | } |
| 1455 | |
| 1456 | if (PREF_CHANGED(HTTP_PREF("max-persistent-connections-per-proxy")"network.http." "max-persistent-connections-per-proxy")) { |
| 1457 | rv = Preferences::GetInt(HTTP_PREF("max-persistent-connections-per-proxy")"network.http." "max-persistent-connections-per-proxy", |
| 1458 | &val); |
| 1459 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1460 | mMaxPersistentConnectionsPerProxy = (uint8_t)std::clamp(val, 1, 0xff); |
| 1461 | if (mConnMgr) { |
| 1462 | rv = mConnMgr->UpdateParam( |
| 1463 | nsHttpConnectionMgr::MAX_PERSISTENT_CONNECTIONS_PER_PROXY, |
| 1464 | mMaxPersistentConnectionsPerProxy); |
| 1465 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 1466 | 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) |
| 1467 | ("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) |
| 1468 | "(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) |
| 1469 | "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) |
| 1470 | 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); |
| 1471 | } |
| 1472 | } |
| 1473 | } |
| 1474 | } |
| 1475 | |
| 1476 | if (PREF_CHANGED(HTTP_PREF("redirection-limit")"network.http." "redirection-limit")) { |
| 1477 | rv = Preferences::GetInt(HTTP_PREF("redirection-limit")"network.http." "redirection-limit", &val); |
| 1478 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) mRedirectionLimit = (uint8_t)std::clamp(val, 0, 0xff); |
| 1479 | } |
| 1480 | |
| 1481 | if (PREF_CHANGED(HTTP_PREF("connection-retry-timeout")"network.http." "connection-retry-timeout")) { |
| 1482 | rv = Preferences::GetInt(HTTP_PREF("connection-retry-timeout")"network.http." "connection-retry-timeout", &val); |
| 1483 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) mIdleSynTimeout = (uint16_t)std::clamp(val, 0, 3000); |
| 1484 | } |
| 1485 | |
| 1486 | if (PREF_CHANGED(HTTP_PREF("fast-fallback-to-IPv4")"network.http." "fast-fallback-to-IPv4")) { |
| 1487 | rv = Preferences::GetBool(HTTP_PREF("fast-fallback-to-IPv4")"network.http." "fast-fallback-to-IPv4", &cVar); |
| 1488 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) mFastFallbackToIPv4 = cVar; |
| 1489 | } |
| 1490 | |
| 1491 | if (PREF_CHANGED(HTTP_PREF("fallback-connection-timeout")"network.http." "fallback-connection-timeout")) { |
| 1492 | rv = Preferences::GetInt(HTTP_PREF("fallback-connection-timeout")"network.http." "fallback-connection-timeout", &val); |
| 1493 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1494 | mFallbackSynTimeout = (uint16_t)std::clamp(val, 0, 10 * 60); |
| 1495 | } |
| 1496 | } |
| 1497 | |
| 1498 | if (PREF_CHANGED(HTTP_PREF("version")"network.http." "version")) { |
| 1499 | nsAutoCString httpVersion; |
| 1500 | Preferences::GetCString(HTTP_PREF("version")"network.http." "version", httpVersion); |
| 1501 | if (!httpVersion.IsVoid()) { |
| 1502 | if (httpVersion.EqualsLiteral("1.1")) { |
| 1503 | mHttpVersion = HttpVersion::v1_1; |
| 1504 | } else if (httpVersion.EqualsLiteral("0.9")) { |
| 1505 | mHttpVersion = HttpVersion::v0_9; |
| 1506 | } else { |
| 1507 | mHttpVersion = HttpVersion::v1_0; |
| 1508 | } |
| 1509 | } |
| 1510 | } |
| 1511 | |
| 1512 | if (PREF_CHANGED(HTTP_PREF("proxy.version")"network.http." "proxy.version")) { |
| 1513 | nsAutoCString httpVersion; |
| 1514 | Preferences::GetCString(HTTP_PREF("proxy.version")"network.http." "proxy.version", httpVersion); |
| 1515 | if (!httpVersion.IsVoid()) { |
| 1516 | if (httpVersion.EqualsLiteral("1.1")) { |
| 1517 | mProxyHttpVersion = HttpVersion::v1_1; |
| 1518 | } else { |
| 1519 | mProxyHttpVersion = HttpVersion::v1_0; |
| 1520 | } |
| 1521 | // it does not make sense to issue a HTTP/0.9 request to a proxy server |
| 1522 | } |
| 1523 | } |
| 1524 | |
| 1525 | if (PREF_CHANGED(HTTP_PREF("proxy.respect-be-conservative")"network.http." "proxy.respect-be-conservative")) { |
| 1526 | rv = |
| 1527 | Preferences::GetBool(HTTP_PREF("proxy.respect-be-conservative")"network.http." "proxy.respect-be-conservative", &cVar); |
| 1528 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1529 | mBeConservativeForProxy = cVar; |
| 1530 | if (mConnMgr) { |
| 1531 | (void)mConnMgr->UpdateParam( |
| 1532 | nsHttpConnectionMgr::PROXY_BE_CONSERVATIVE, |
| 1533 | static_cast<int32_t>(mBeConservativeForProxy)); |
| 1534 | } |
| 1535 | } |
| 1536 | } |
| 1537 | |
| 1538 | if (PREF_CHANGED(HTTP_PREF("qos")"network.http." "qos")) { |
| 1539 | rv = Preferences::GetInt(HTTP_PREF("qos")"network.http." "qos", &val); |
| 1540 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) mQoSBits = (uint8_t)std::clamp(val, 0, 0xff); |
| 1541 | } |
| 1542 | |
| 1543 | if (PREF_CHANGED(HTTP_PREF("accept-encoding")"network.http." "accept-encoding")) { |
| 1544 | nsAutoCString acceptEncodings; |
| 1545 | rv = Preferences::GetCString(HTTP_PREF("accept-encoding")"network.http." "accept-encoding", acceptEncodings); |
| 1546 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1547 | rv = SetAcceptEncodings(acceptEncodings.get(), false, false); |
| 1548 | 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" , 1548); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))" ")"); do { MOZ_CrashSequence(__null, 1548); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 1549 | } |
| 1550 | } |
| 1551 | |
| 1552 | if (PREF_CHANGED(HTTP_PREF("accept-encoding.secure")"network.http." "accept-encoding.secure") || |
| 1553 | PREF_CHANGED(HTTP_PREF("accept-encoding.dictionary")"network.http." "accept-encoding.dictionary")) { |
| 1554 | nsAutoCString acceptEncodings; |
| 1555 | rv = Preferences::GetCString(HTTP_PREF("accept-encoding.secure")"network.http." "accept-encoding.secure", |
| 1556 | acceptEncodings); |
| 1557 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1558 | rv = SetAcceptEncodings(acceptEncodings.get(), true, false); |
| 1559 | |
| 1560 | // Since dictionary encodings are dependent on both accept-encoding.secure |
| 1561 | // and accept-encoding.dictionary, update both if either changes (which is |
| 1562 | // quite rare, so there's no real perf hit) |
| 1563 | nsAutoCString acceptDictionaryEncodings; |
| 1564 | nsresult rvDic = Preferences::GetCString( |
| 1565 | HTTP_PREF("accept-encoding.dictionary")"network.http." "accept-encoding.dictionary", acceptDictionaryEncodings); |
| 1566 | if (NS_SUCCEEDED(rvDic)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rvDic)), 1))) && !acceptDictionaryEncodings.IsEmpty()) { |
| 1567 | acceptEncodings.Append(", "_ns); |
| 1568 | acceptEncodings.Append(acceptDictionaryEncodings); |
| 1569 | rv = SetAcceptEncodings(acceptEncodings.get(), true, true); |
| 1570 | } |
| 1571 | 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" , 1571); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))" ")"); do { MOZ_CrashSequence(__null, 1571); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 1572 | } |
| 1573 | } |
| 1574 | |
| 1575 | if (PREF_CHANGED(HTTP_PREF("default-socket-type")"network.http." "default-socket-type")) { |
| 1576 | nsAutoCString sval; |
| 1577 | rv = Preferences::GetCString(HTTP_PREF("default-socket-type")"network.http." "default-socket-type", sval); |
| 1578 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1579 | if (sval.IsEmpty()) { |
| 1580 | mDefaultSocketType.SetIsVoid(true); |
| 1581 | } else { |
| 1582 | // verify that this socket type is actually valid |
| 1583 | nsCOMPtr<nsISocketProviderService> sps = |
| 1584 | nsSocketProviderService::GetOrCreate(); |
| 1585 | if (sps) { |
| 1586 | nsCOMPtr<nsISocketProvider> sp; |
| 1587 | rv = sps->GetSocketProvider(sval.get(), getter_AddRefs(sp)); |
| 1588 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1589 | // OK, this looks like a valid socket provider. |
| 1590 | mDefaultSocketType.Assign(sval); |
| 1591 | } |
| 1592 | } |
| 1593 | } |
| 1594 | } |
| 1595 | } |
| 1596 | |
| 1597 | if (PREF_CHANGED(HTTP_PREF("prompt-temp-redirect")"network.http." "prompt-temp-redirect")) { |
| 1598 | rv = Preferences::GetBool(HTTP_PREF("prompt-temp-redirect")"network.http." "prompt-temp-redirect", &cVar); |
| 1599 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1600 | mPromptTempRedirect = cVar; |
| 1601 | } |
| 1602 | } |
| 1603 | |
| 1604 | if (PREF_CHANGED(HTTP_PREF("assoc-req.enforce")"network.http." "assoc-req.enforce")) { |
| 1605 | cVar = false; |
| 1606 | rv = Preferences::GetBool(HTTP_PREF("assoc-req.enforce")"network.http." "assoc-req.enforce", &cVar); |
| 1607 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) mEnforceAssocReq = cVar; |
| 1608 | } |
| 1609 | |
| 1610 | // enable Persistent caching for HTTPS - bug#205921 |
| 1611 | if (PREF_CHANGED(BROWSER_PREF("disk_cache_ssl")"browser.cache." "disk_cache_ssl")) { |
| 1612 | cVar = false; |
| 1613 | rv = Preferences::GetBool(BROWSER_PREF("disk_cache_ssl")"browser.cache." "disk_cache_ssl", &cVar); |
| 1614 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) mEnablePersistentHttpsCaching = cVar; |
| 1615 | } |
| 1616 | |
| 1617 | if (PREF_CHANGED(HTTP_PREF("http2.timeout")"network.http." "http2.timeout")) { |
| 1618 | mSpdyTimeout = PR_SecondsToInterval( |
| 1619 | std::clamp(StaticPrefs::network_http_http2_timeout(), 1, 0xffff)); |
| 1620 | } |
| 1621 | |
| 1622 | if (PREF_CHANGED(HTTP_PREF("http2.chunk-size")"network.http." "http2.chunk-size")) { |
| 1623 | // keep this within http/2 ranges of 1 to 2^24-1 |
| 1624 | mSpdySendingChunkSize = (uint32_t)std::clamp( |
| 1625 | StaticPrefs::network_http_http2_chunk_size(), 1, 0xffffff); |
| 1626 | } |
| 1627 | |
| 1628 | // The amount of idle seconds on a http2 connection before initiating a |
| 1629 | // server ping. 0 will disable. |
| 1630 | if (PREF_CHANGED(HTTP_PREF("http2.ping-threshold")"network.http." "http2.ping-threshold")) { |
| 1631 | mSpdyPingThreshold = PR_SecondsToInterval((uint16_t)std::clamp( |
| 1632 | StaticPrefs::network_http_http2_ping_threshold(), 0, 0x7fffffff)); |
| 1633 | } |
| 1634 | |
| 1635 | // The amount of seconds to wait for a http2 ping response before |
| 1636 | // closing the session. |
| 1637 | if (PREF_CHANGED(HTTP_PREF("http2.ping-timeout")"network.http." "http2.ping-timeout")) { |
| 1638 | mSpdyPingTimeout = PR_SecondsToInterval((uint16_t)std::clamp( |
| 1639 | StaticPrefs::network_http_http2_ping_timeout(), 0, 0x7fffffff)); |
| 1640 | } |
| 1641 | |
| 1642 | if (PREF_CHANGED(HTTP_PREF("altsvc.enabled")"network.http." "altsvc.enabled")) { |
| 1643 | rv = Preferences::GetBool(HTTP_PREF("altsvc.enabled")"network.http." "altsvc.enabled", &cVar); |
| 1644 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) mEnableAltSvc = cVar; |
| 1645 | } |
| 1646 | |
| 1647 | if (PREF_CHANGED(HTTP_PREF("http2.push-allowance")"network.http." "http2.push-allowance")) { |
| 1648 | mSpdyPushAllowance = static_cast<uint32_t>( |
| 1649 | std::clamp(StaticPrefs::network_http_http2_push_allowance(), 1024, |
| 1650 | static_cast<int32_t>(ASpdySession::kInitialRwin))); |
| 1651 | } |
| 1652 | |
| 1653 | if (PREF_CHANGED(HTTP_PREF("http2.pull-allowance")"network.http." "http2.pull-allowance")) { |
| 1654 | mSpdyPullAllowance = static_cast<uint32_t>(std::clamp( |
| 1655 | StaticPrefs::network_http_http2_pull_allowance(), 1024, 0x7fffffff)); |
| 1656 | } |
| 1657 | |
| 1658 | if (PREF_CHANGED(HTTP_PREF("http2.default-concurrent")"network.http." "http2.default-concurrent")) { |
| 1659 | mDefaultSpdyConcurrent = static_cast<uint32_t>(std::max<int32_t>( |
| 1660 | std::min<int32_t>(StaticPrefs::network_http_http2_default_concurrent(), |
| 1661 | 9999), |
| 1662 | 1)); |
| 1663 | } |
| 1664 | |
| 1665 | // If http2.send-buffer-size is non-zero, the size to set the TCP |
| 1666 | // sendbuffer to once the stream has surpassed this number of bytes uploaded |
| 1667 | if (PREF_CHANGED(HTTP_PREF("http2.send-buffer-size")"network.http." "http2.send-buffer-size")) { |
| 1668 | mSpdySendBufferSize = (uint32_t)std::clamp( |
| 1669 | StaticPrefs::network_http_http2_send_buffer_size(), 1500, 0x7fffffff); |
| 1670 | } |
| 1671 | |
| 1672 | // The maximum amount of time to wait for socket transport to be |
| 1673 | // established |
| 1674 | if (PREF_CHANGED(HTTP_PREF("connection-timeout")"network.http." "connection-timeout")) { |
| 1675 | rv = Preferences::GetInt(HTTP_PREF("connection-timeout")"network.http." "connection-timeout", &val); |
| 1676 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1677 | // the pref is in seconds, but the variable is in milliseconds |
| 1678 | mConnectTimeout = std::clamp(val, 1, 0xffff) * PR_MSEC_PER_SEC1000L; |
| 1679 | } |
| 1680 | } |
| 1681 | |
| 1682 | // The maximum amount of time to wait for a tls handshake to finish. |
| 1683 | if (PREF_CHANGED(HTTP_PREF("tls-handshake-timeout")"network.http." "tls-handshake-timeout")) { |
| 1684 | rv = Preferences::GetInt(HTTP_PREF("tls-handshake-timeout")"network.http." "tls-handshake-timeout", &val); |
| 1685 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1686 | // the pref is in seconds, but the variable is in milliseconds |
| 1687 | mTLSHandshakeTimeout = std::clamp(val, 1, 0xffff) * PR_MSEC_PER_SEC1000L; |
| 1688 | } |
| 1689 | } |
| 1690 | |
| 1691 | // The maximum number of current global half open sockets allowable |
| 1692 | // for starting a new speculative connection. |
| 1693 | if (PREF_CHANGED(HTTP_PREF("speculative-parallel-limit")"network.http." "speculative-parallel-limit")) { |
| 1694 | rv = Preferences::GetInt(HTTP_PREF("speculative-parallel-limit")"network.http." "speculative-parallel-limit", &val); |
| 1695 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1696 | mParallelSpeculativeConnectLimit = (uint32_t)std::clamp(val, 0, 1024); |
| 1697 | } |
| 1698 | } |
| 1699 | |
| 1700 | // Whether or not to block requests for non head js/css items (e.g. media) |
| 1701 | // while those elements load. |
| 1702 | if (PREF_CHANGED(HTTP_PREF("rendering-critical-requests-prioritization")"network.http." "rendering-critical-requests-prioritization")) { |
| 1703 | rv = Preferences::GetBool( |
| 1704 | HTTP_PREF("rendering-critical-requests-prioritization")"network.http." "rendering-critical-requests-prioritization", &cVar); |
| 1705 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) mCriticalRequestPrioritization = cVar; |
| 1706 | } |
| 1707 | |
| 1708 | // on transition of network.http.diagnostics to true print |
| 1709 | // a bunch of information to the console |
| 1710 | if (pref && PREF_CHANGED(HTTP_PREF("diagnostics")"network.http." "diagnostics")) { |
| 1711 | rv = Preferences::GetBool(HTTP_PREF("diagnostics")"network.http." "diagnostics", &cVar); |
| 1712 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cVar) { |
| 1713 | if (mConnMgr) mConnMgr->PrintDiagnostics(); |
| 1714 | } |
| 1715 | } |
| 1716 | |
| 1717 | if (PREF_CHANGED(HTTP_PREF("throttle.enable")"network.http." "throttle.enable")) { |
| 1718 | rv = Preferences::GetBool(HTTP_PREF("throttle.enable")"network.http." "throttle.enable", &mThrottleEnabled); |
| 1719 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && mConnMgr) { |
| 1720 | (void)mConnMgr->UpdateParam(nsHttpConnectionMgr::THROTTLING_ENABLED, |
| 1721 | static_cast<int32_t>(mThrottleEnabled)); |
| 1722 | } |
| 1723 | } |
| 1724 | |
| 1725 | if (PREF_CHANGED(HTTP_PREF("throttle.suspend-for")"network.http." "throttle.suspend-for")) { |
| 1726 | rv = Preferences::GetInt(HTTP_PREF("throttle.suspend-for")"network.http." "throttle.suspend-for", &val); |
| 1727 | mThrottleSuspendFor = (uint32_t)std::clamp(val, 0, 120000); |
| 1728 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && mConnMgr) { |
| 1729 | (void)mConnMgr->UpdateParam(nsHttpConnectionMgr::THROTTLING_SUSPEND_FOR, |
| 1730 | mThrottleSuspendFor); |
| 1731 | } |
| 1732 | } |
| 1733 | |
| 1734 | if (PREF_CHANGED(HTTP_PREF("throttle.resume-for")"network.http." "throttle.resume-for")) { |
| 1735 | rv = Preferences::GetInt(HTTP_PREF("throttle.resume-for")"network.http." "throttle.resume-for", &val); |
| 1736 | mThrottleResumeFor = (uint32_t)std::clamp(val, 0, 120000); |
| 1737 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && mConnMgr) { |
| 1738 | (void)mConnMgr->UpdateParam(nsHttpConnectionMgr::THROTTLING_RESUME_FOR, |
| 1739 | mThrottleResumeFor); |
| 1740 | } |
| 1741 | } |
| 1742 | |
| 1743 | if (PREF_CHANGED(HTTP_PREF("throttle.hold-time-ms")"network.http." "throttle.hold-time-ms")) { |
| 1744 | rv = Preferences::GetInt(HTTP_PREF("throttle.hold-time-ms")"network.http." "throttle.hold-time-ms", &val); |
| 1745 | mThrottleHoldTime = (uint32_t)std::clamp(val, 0, 120000); |
| 1746 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && mConnMgr) { |
| 1747 | (void)mConnMgr->UpdateParam(nsHttpConnectionMgr::THROTTLING_HOLD_TIME, |
| 1748 | mThrottleHoldTime); |
| 1749 | } |
| 1750 | } |
| 1751 | |
| 1752 | if (PREF_CHANGED(HTTP_PREF("throttle.max-time-ms")"network.http." "throttle.max-time-ms")) { |
| 1753 | rv = Preferences::GetInt(HTTP_PREF("throttle.max-time-ms")"network.http." "throttle.max-time-ms", &val); |
| 1754 | mThrottleMaxTime = (uint32_t)std::clamp(val, 0, 120000); |
| 1755 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && mConnMgr) { |
| 1756 | (void)mConnMgr->UpdateParam(nsHttpConnectionMgr::THROTTLING_MAX_TIME, |
| 1757 | mThrottleMaxTime); |
| 1758 | } |
| 1759 | } |
| 1760 | |
| 1761 | if (PREF_CHANGED(HTTP_PREF("send_window_size")"network.http." "send_window_size")) { |
| 1762 | (void)Preferences::GetInt(HTTP_PREF("send_window_size")"network.http." "send_window_size", &val); |
| 1763 | mSendWindowSize = val >= 0 ? val : 0; |
| 1764 | } |
| 1765 | |
| 1766 | if (PREF_CHANGED(HTTP_PREF("on_click_priority")"network.http." "on_click_priority")) { |
| 1767 | (void)Preferences::GetBool(HTTP_PREF("on_click_priority")"network.http." "on_click_priority", |
| 1768 | &mUrgentStartEnabled); |
| 1769 | } |
| 1770 | |
| 1771 | if (PREF_CHANGED(HTTP_PREF("tailing.enabled")"network.http." "tailing.enabled")) { |
| 1772 | (void)Preferences::GetBool(HTTP_PREF("tailing.enabled")"network.http." "tailing.enabled", |
| 1773 | &mTailBlockingEnabled); |
| 1774 | } |
| 1775 | if (PREF_CHANGED(HTTP_PREF("tailing.delay-quantum")"network.http." "tailing.delay-quantum")) { |
| 1776 | val = StaticPrefs::network_http_tailing_delay_quantum(); |
| 1777 | mTailDelayQuantum = (uint32_t)std::clamp(val, 0, 60000); |
| 1778 | } |
| 1779 | if (PREF_CHANGED(HTTP_PREF("tailing.delay-quantum-after-domcontentloaded")"network.http." "tailing.delay-quantum-after-domcontentloaded")) { |
| 1780 | val = StaticPrefs:: |
| 1781 | network_http_tailing_delay_quantum_after_domcontentloaded(); |
| 1782 | mTailDelayQuantumAfterDCL = (uint32_t)std::clamp(val, 0, 60000); |
| 1783 | } |
| 1784 | if (PREF_CHANGED(HTTP_PREF("tailing.delay-max")"network.http." "tailing.delay-max")) { |
| 1785 | val = StaticPrefs::network_http_tailing_delay_max(); |
| 1786 | mTailDelayMax = (uint32_t)std::clamp(val, 0, 60000); |
| 1787 | } |
| 1788 | if (PREF_CHANGED(HTTP_PREF("tailing.total-max")"network.http." "tailing.total-max")) { |
| 1789 | val = StaticPrefs::network_http_tailing_total_max(); |
| 1790 | mTailTotalMax = (uint32_t)std::clamp(val, 0, 60000); |
| 1791 | } |
| 1792 | |
| 1793 | if (PREF_CHANGED(HTTP_PREF("focused_window_transaction_ratio")"network.http." "focused_window_transaction_ratio")) { |
| 1794 | float ratio = 0; |
| 1795 | rv = Preferences::GetFloat(HTTP_PREF("focused_window_transaction_ratio")"network.http." "focused_window_transaction_ratio", |
| 1796 | &ratio); |
| 1797 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1798 | if (ratio > 0 && ratio < 1) { |
| 1799 | mFocusedWindowTransactionRatio = ratio; |
| 1800 | } else { |
| 1801 | 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" , 1801); |
| 1802 | } |
| 1803 | } |
| 1804 | } |
| 1805 | |
| 1806 | // |
| 1807 | // INTL options |
| 1808 | // |
| 1809 | |
| 1810 | if (PREF_CHANGED(INTL_ACCEPT_LANGUAGES"intl.accept_languages")) { |
| 1811 | // We don't want to set the new accept languages here since |
| 1812 | // this pref is a complex type and it may be racy with flushing |
| 1813 | // string resources. |
| 1814 | mAcceptLanguagesIsDirty = true; |
| 1815 | } |
| 1816 | |
| 1817 | // |
| 1818 | // Tracking options |
| 1819 | // |
| 1820 | |
| 1821 | // Hint option |
| 1822 | if (PREF_CHANGED(SAFE_HINT_HEADER_VALUE"safeHint.enabled")) { |
| 1823 | cVar = false; |
| 1824 | rv = Preferences::GetBool(SAFE_HINT_HEADER_VALUE"safeHint.enabled", &cVar); |
| 1825 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1826 | mSafeHintEnabled = cVar; |
| 1827 | } |
| 1828 | } |
| 1829 | |
| 1830 | // toggle to true anytime a token bucket related pref is changed.. that |
| 1831 | // includes telemetry and allow-experiments because of the abtest profile |
| 1832 | bool requestTokenBucketUpdated = false; |
| 1833 | |
| 1834 | // "security.ssl3.ecdhe_rsa_aes_128_gcm_sha256" is the required h2 interop |
| 1835 | // suite. |
| 1836 | |
| 1837 | if (PREF_CHANGED(H2MANDATORY_SUITE"security.ssl3.ecdhe_rsa_aes_128_gcm_sha256")) { |
| 1838 | cVar = false; |
| 1839 | rv = Preferences::GetBool(H2MANDATORY_SUITE"security.ssl3.ecdhe_rsa_aes_128_gcm_sha256", &cVar); |
| 1840 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1841 | mH2MandatorySuiteEnabled = cVar; |
| 1842 | } |
| 1843 | } |
| 1844 | |
| 1845 | // network.http.debug-observations |
| 1846 | if (PREF_CHANGED("network.http.debug-observations")) { |
| 1847 | cVar = false; |
| 1848 | rv = Preferences::GetBool("network.http.debug-observations", &cVar); |
| 1849 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1850 | mDebugObservations = cVar; |
| 1851 | } |
| 1852 | } |
| 1853 | |
| 1854 | if (PREF_CHANGED(HTTP_PREF("pacing.requests.enabled")"network.http." "pacing.requests.enabled")) { |
| 1855 | rv = Preferences::GetBool(HTTP_PREF("pacing.requests.enabled")"network.http." "pacing.requests.enabled", &cVar); |
| 1856 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1857 | mRequestTokenBucketEnabled = cVar; |
| 1858 | requestTokenBucketUpdated = true; |
| 1859 | } |
| 1860 | } |
| 1861 | if (PREF_CHANGED(HTTP_PREF("pacing.requests.min-parallelism")"network.http." "pacing.requests.min-parallelism")) { |
| 1862 | rv = |
| 1863 | Preferences::GetInt(HTTP_PREF("pacing.requests.min-parallelism")"network.http." "pacing.requests.min-parallelism", &val); |
| 1864 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1865 | mRequestTokenBucketMinParallelism = |
| 1866 | static_cast<uint16_t>(std::clamp(val, 1, 1024)); |
| 1867 | requestTokenBucketUpdated = true; |
| 1868 | } |
| 1869 | } |
| 1870 | if (PREF_CHANGED(HTTP_PREF("pacing.requests.hz")"network.http." "pacing.requests.hz")) { |
| 1871 | rv = Preferences::GetInt(HTTP_PREF("pacing.requests.hz")"network.http." "pacing.requests.hz", &val); |
| 1872 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1873 | mRequestTokenBucketHz = static_cast<uint32_t>(std::clamp(val, 1, 10000)); |
| 1874 | requestTokenBucketUpdated = true; |
| 1875 | } |
| 1876 | } |
| 1877 | if (PREF_CHANGED(HTTP_PREF("pacing.requests.burst")"network.http." "pacing.requests.burst")) { |
| 1878 | rv = Preferences::GetInt(HTTP_PREF("pacing.requests.burst")"network.http." "pacing.requests.burst", &val); |
| 1879 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1880 | mRequestTokenBucketBurst = val ? val : 1; |
| 1881 | requestTokenBucketUpdated = true; |
| 1882 | } |
| 1883 | } |
| 1884 | if (requestTokenBucketUpdated) { |
| 1885 | MakeNewRequestTokenBucket(); |
| 1886 | } |
| 1887 | |
| 1888 | // Keepalive values for initial and idle connections. |
| 1889 | if (PREF_CHANGED(HTTP_PREF("tcp_keepalive.short_lived_connections")"network.http." "tcp_keepalive.short_lived_connections")) { |
| 1890 | rv = Preferences::GetBool( |
| 1891 | HTTP_PREF("tcp_keepalive.short_lived_connections")"network.http." "tcp_keepalive.short_lived_connections", &cVar); |
| 1892 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cVar != mTCPKeepaliveShortLivedEnabled) { |
| 1893 | mTCPKeepaliveShortLivedEnabled = cVar; |
| 1894 | } |
| 1895 | } |
| 1896 | |
| 1897 | if (PREF_CHANGED(HTTP_PREF("tcp_keepalive.short_lived_time")"network.http." "tcp_keepalive.short_lived_time")) { |
| 1898 | rv = Preferences::GetInt(HTTP_PREF("tcp_keepalive.short_lived_time")"network.http." "tcp_keepalive.short_lived_time", &val); |
| 1899 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && val > 0) { |
| 1900 | mTCPKeepaliveShortLivedTimeS = std::clamp(val, 1, 300); // Max 5 mins. |
| 1901 | } |
| 1902 | } |
| 1903 | |
| 1904 | if (PREF_CHANGED(HTTP_PREF("tcp_keepalive.short_lived_idle_time")"network.http." "tcp_keepalive.short_lived_idle_time")) { |
| 1905 | rv = Preferences::GetInt(HTTP_PREF("tcp_keepalive.short_lived_idle_time")"network.http." "tcp_keepalive.short_lived_idle_time", |
| 1906 | &val); |
| 1907 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && val > 0) { |
| 1908 | mTCPKeepaliveShortLivedIdleTimeS = std::clamp(val, 1, kMaxTCPKeepIdle); |
| 1909 | } |
| 1910 | } |
| 1911 | |
| 1912 | // Keepalive values for Long-lived Connections. |
| 1913 | if (PREF_CHANGED(HTTP_PREF("tcp_keepalive.long_lived_connections")"network.http." "tcp_keepalive.long_lived_connections")) { |
| 1914 | rv = Preferences::GetBool(HTTP_PREF("tcp_keepalive.long_lived_connections")"network.http." "tcp_keepalive.long_lived_connections", |
| 1915 | &cVar); |
| 1916 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cVar != mTCPKeepaliveLongLivedEnabled) { |
| 1917 | mTCPKeepaliveLongLivedEnabled = cVar; |
| 1918 | } |
| 1919 | } |
| 1920 | |
| 1921 | if (PREF_CHANGED(HTTP_PREF("tcp_keepalive.long_lived_idle_time")"network.http." "tcp_keepalive.long_lived_idle_time")) { |
| 1922 | rv = Preferences::GetInt(HTTP_PREF("tcp_keepalive.long_lived_idle_time")"network.http." "tcp_keepalive.long_lived_idle_time", |
| 1923 | &val); |
| 1924 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && val > 0) { |
| 1925 | mTCPKeepaliveLongLivedIdleTimeS = std::clamp(val, 1, kMaxTCPKeepIdle); |
| 1926 | } |
| 1927 | } |
| 1928 | |
| 1929 | if (PREF_CHANGED(HTTP_PREF("enforce-framing.http1")"network.http." "enforce-framing.http1") || |
| 1930 | PREF_CHANGED(HTTP_PREF("enforce-framing.soft")"network.http." "enforce-framing.soft") || |
| 1931 | PREF_CHANGED(HTTP_PREF("enforce-framing.strict_chunked_encoding")"network.http." "enforce-framing.strict_chunked_encoding")) { |
| 1932 | rv = Preferences::GetBool(HTTP_PREF("enforce-framing.http1")"network.http." "enforce-framing.http1", &cVar); |
| 1933 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cVar) { |
| 1934 | mEnforceH1Framing = FRAMECHECK_STRICT; |
| 1935 | } else { |
| 1936 | rv = Preferences::GetBool( |
| 1937 | HTTP_PREF("enforce-framing.strict_chunked_encoding")"network.http." "enforce-framing.strict_chunked_encoding", &cVar); |
| 1938 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cVar) { |
| 1939 | mEnforceH1Framing = FRAMECHECK_STRICT_CHUNKED; |
| 1940 | } else { |
| 1941 | rv = Preferences::GetBool(HTTP_PREF("enforce-framing.soft")"network.http." "enforce-framing.soft", &cVar); |
| 1942 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cVar) { |
| 1943 | mEnforceH1Framing = FRAMECHECK_BARELY; |
| 1944 | } else { |
| 1945 | mEnforceH1Framing = FRAMECHECK_LAX; |
| 1946 | } |
| 1947 | } |
| 1948 | } |
| 1949 | } |
| 1950 | |
| 1951 | if (PREF_CHANGED(HTTP_PREF("http2.default-hpack-buffer")"network.http." "http2.default-hpack-buffer")) { |
| 1952 | mDefaultHpackBuffer = |
| 1953 | StaticPrefs::network_http_http2_default_hpack_buffer(); |
| 1954 | } |
| 1955 | |
| 1956 | if (PREF_CHANGED(HTTP_PREF("http3.default-qpack-table-size")"network.http." "http3.default-qpack-table-size")) { |
| 1957 | rv = Preferences::GetInt(HTTP_PREF("http3.default-qpack-table-size")"network.http." "http3.default-qpack-table-size", &val); |
| 1958 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1959 | mQpackTableSize = val; |
| 1960 | } |
| 1961 | } |
| 1962 | |
| 1963 | if (PREF_CHANGED(HTTP_PREF("http3.default-max-stream-blocked")"network.http." "http3.default-max-stream-blocked")) { |
| 1964 | rv = Preferences::GetInt(HTTP_PREF("http3.default-max-stream-blocked")"network.http." "http3.default-max-stream-blocked", |
| 1965 | &val); |
| 1966 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 1967 | mHttp3MaxBlockedStreams = std::clamp(val, 0, 0xffff); |
| 1968 | } |
| 1969 | } |
| 1970 | |
| 1971 | const bool imageAcceptPrefChanged = |
| 1972 | PREF_CHANGED("image.http.accept") || PREF_CHANGED("image.jxl.enabled"); |
| 1973 | |
| 1974 | if (imageAcceptPrefChanged) { |
| 1975 | nsAutoCString userSetImageAcceptHeader; |
| 1976 | |
| 1977 | if (Preferences::HasUserValue("image.http.accept")) { |
| 1978 | rv = Preferences::GetCString("image.http.accept", |
| 1979 | userSetImageAcceptHeader); |
| 1980 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 1981 | userSetImageAcceptHeader.Truncate(); |
| 1982 | } |
| 1983 | } |
| 1984 | |
| 1985 | if (userSetImageAcceptHeader.IsEmpty()) { |
| 1986 | mImageAcceptHeader.Assign(ImageAcceptHeader()); |
| 1987 | } else { |
| 1988 | mImageAcceptHeader.Assign(userSetImageAcceptHeader); |
| 1989 | } |
| 1990 | } |
| 1991 | |
| 1992 | if (PREF_CHANGED("network.http.accept") || imageAcceptPrefChanged) { |
| 1993 | nsAutoCString userSetDocumentAcceptHeader; |
| 1994 | |
| 1995 | if (Preferences::HasUserValue("network.http.accept")) { |
| 1996 | rv = Preferences::GetCString("network.http.accept", |
| 1997 | userSetDocumentAcceptHeader); |
| 1998 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 1999 | userSetDocumentAcceptHeader.Truncate(); |
| 2000 | } |
| 2001 | } |
| 2002 | |
| 2003 | if (userSetDocumentAcceptHeader.IsEmpty()) { |
| 2004 | mDocumentAcceptHeader.Assign(DocumentAcceptHeader()); |
| 2005 | } else { |
| 2006 | mDocumentAcceptHeader.Assign(userSetDocumentAcceptHeader); |
| 2007 | } |
| 2008 | } |
| 2009 | |
| 2010 | if (PREF_CHANGED(HTTP_PREF("http3.alt-svc-mapping-for-testing")"network.http." "http3.alt-svc-mapping-for-testing")) { |
| 2011 | nsAutoCString altSvcMappings; |
| 2012 | rv = Preferences::GetCString(HTTP_PREF("http3.alt-svc-mapping-for-testing")"network.http." "http3.alt-svc-mapping-for-testing", |
| 2013 | altSvcMappings); |
| 2014 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 2015 | if (altSvcMappings.IsEmpty()) { |
| 2016 | mAltSvcMappingTemptativeMap.Clear(); |
| 2017 | } else { |
| 2018 | for (const nsACString& tokenSubstring : |
| 2019 | nsCCharSeparatedTokenizer(altSvcMappings, ',').ToRange()) { |
| 2020 | nsAutoCString token{tokenSubstring}; |
| 2021 | int32_t index = token.Find(";"); |
| 2022 | if (index != kNotFound) { |
| 2023 | mAltSvcMappingTemptativeMap.InsertOrUpdate( |
| 2024 | Substring(token, 0, index), |
| 2025 | MakeUnique<nsCString>(Substring(token, index + 1))); |
| 2026 | } |
| 2027 | } |
| 2028 | } |
| 2029 | } |
| 2030 | } |
| 2031 | |
| 2032 | if (PREF_CHANGED(HTTP_PREF("http3.enable_qlog")"network.http." "http3.enable_qlog")) { |
| 2033 | // Initialize the directory. |
| 2034 | nsCOMPtr<nsIFile> qlogDir; |
| 2035 | if (Preferences::GetBool(HTTP_PREF("http3.enable_qlog")"network.http." "http3.enable_qlog") && |
| 2036 | !mHttp3QlogDir.IsEmpty() && |
| 2037 | NS_SUCCEEDED(((bool)(__builtin_expect(!!(!NS_FAILED_impl(NS_NewNativeLocalFile (mHttp3QlogDir, getter_AddRefs(qlogDir)))), 1))) |
| 2038 | NS_NewNativeLocalFile(mHttp3QlogDir, getter_AddRefs(qlogDir)))((bool)(__builtin_expect(!!(!NS_FAILED_impl(NS_NewNativeLocalFile (mHttp3QlogDir, getter_AddRefs(qlogDir)))), 1)))) { |
| 2039 | // Here we do main thread IO, but since this only happens |
| 2040 | // when enabling a developer feature it's not a problem for users. |
| 2041 | rv = qlogDir->Create(nsIFile::DIRECTORY_TYPE, 0755); |
| 2042 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0))) && rv != NS_ERROR_FILE_ALREADY_EXISTS) { |
| 2043 | NS_WARNING("Creating qlog dir failed")NS_DebugBreak(NS_DEBUG_WARNING, "Creating qlog dir failed", nullptr , "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp" , 2043); |
| 2044 | } |
| 2045 | } |
| 2046 | } |
| 2047 | |
| 2048 | #ifdef XP_MACOSX |
| 2049 | if (XRE_IsParentProcess()) { |
| 2050 | if (PREF_CHANGED(HTTP_PREF("microsoft-entra-sso.enabled")"network.http." "microsoft-entra-sso.enabled")) { |
| 2051 | rv = |
| 2052 | Preferences::GetBool(HTTP_PREF("microsoft-entra-sso.enabled")"network.http." "microsoft-entra-sso.enabled", &cVar); |
| 2053 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cVar) { |
| 2054 | InitMSAuthorities(); |
| 2055 | } |
| 2056 | } |
| 2057 | } |
| 2058 | #endif |
| 2059 | |
| 2060 | // Enable HTTP response timeout if TCP Keepalives are disabled. |
| 2061 | mResponseTimeoutEnabled = |
| 2062 | !mTCPKeepaliveShortLivedEnabled && !mTCPKeepaliveLongLivedEnabled; |
| 2063 | |
| 2064 | #undef PREF_CHANGED |
| 2065 | #undef MULTI_PREF_CHANGED |
| 2066 | } |
| 2067 | |
| 2068 | /** |
| 2069 | * Allocates a C string into that contains a ISO 639 language list |
| 2070 | * notated with HTTP "q" values for output with a HTTP Accept-Language |
| 2071 | * header. Previous q values will be stripped because the order of |
| 2072 | * the langs imply the q value. The q values are calculated by dividing |
| 2073 | * 1.0 amongst the number of languages present. |
| 2074 | * |
| 2075 | * Ex: passing: "en, ja" |
| 2076 | * returns: "en,ja;q=0.5" |
| 2077 | * |
| 2078 | * passing: "en, ja, fr_CA" |
| 2079 | * returns: "en,ja;q=0.7,fr_CA;q=0.3" |
| 2080 | */ |
| 2081 | static nsresult PrepareAcceptLanguages(const char* i_AcceptLanguages, |
| 2082 | nsACString& o_AcceptLanguages) { |
| 2083 | if (!i_AcceptLanguages) return NS_OK; |
| 2084 | |
| 2085 | const nsAutoCString ns_accept_languages(i_AcceptLanguages); |
| 2086 | return rust_prepare_accept_languages(&ns_accept_languages, |
| 2087 | &o_AcceptLanguages); |
| 2088 | } |
| 2089 | |
| 2090 | // Ensure that we've fetched the AcceptLanguages setting |
| 2091 | /* static */ |
| 2092 | void nsHttpHandler::PresetAcceptLanguages() { |
| 2093 | if (!gHttpHandler) { |
| 2094 | RefPtr<nsHttpHandler> handler = nsHttpHandler::GetInstance(); |
| 2095 | (void)handler.get(); |
| 2096 | } |
| 2097 | [[maybe_unused]] nsresult rv = gHttpHandler->SetAcceptLanguages(); |
| 2098 | } |
| 2099 | |
| 2100 | nsresult nsHttpHandler::SetAcceptLanguages() { |
| 2101 | if (!NS_IsMainThread()) { |
| 2102 | nsCOMPtr<nsIThread> mainThread; |
| 2103 | nsresult rv = NS_GetMainThread(getter_AddRefs(mainThread)); |
| 2104 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 2105 | return rv; |
| 2106 | } |
| 2107 | |
| 2108 | // Forward to the main thread synchronously. |
| 2109 | SyncRunnable::DispatchToThread( |
| 2110 | mainThread, |
| 2111 | NS_NewRunnableFunction("nsHttpHandler::SetAcceptLanguages", [&rv]() { |
| 2112 | rv = gHttpHandler->SetAcceptLanguages(); |
| 2113 | })); |
| 2114 | return rv; |
| 2115 | } |
| 2116 | |
| 2117 | 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" , 2117); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { MOZ_CrashSequence(__null, 2117); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 2118 | |
| 2119 | mAcceptLanguagesIsDirty = false; |
| 2120 | |
| 2121 | nsAutoCString acceptLanguages; |
| 2122 | intl::LocaleService::GetInstance()->GetAcceptLanguages(acceptLanguages); |
| 2123 | |
| 2124 | nsAutoCString buf; |
| 2125 | nsresult rv = PrepareAcceptLanguages(acceptLanguages.get(), buf); |
| 2126 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 2127 | mAcceptLanguages.Assign(buf); |
| 2128 | } |
| 2129 | return rv; |
| 2130 | } |
| 2131 | |
| 2132 | nsresult nsHttpHandler::SetAcceptEncodings(const char* aAcceptEncodings, |
| 2133 | bool isSecure, bool isDictionary) { |
| 2134 | if (isDictionary) { |
| 2135 | mDictionaryAcceptEncodings = aAcceptEncodings; |
| 2136 | } else if (isSecure) { |
| 2137 | mHttpsAcceptEncodings = aAcceptEncodings; |
| 2138 | } else { |
| 2139 | // use legacy list if a secure override is not specified |
| 2140 | mHttpAcceptEncodings = aAcceptEncodings; |
| 2141 | if (mHttpsAcceptEncodings.IsEmpty()) { |
| 2142 | mHttpsAcceptEncodings = aAcceptEncodings; |
| 2143 | } |
| 2144 | } |
| 2145 | |
| 2146 | return NS_OK; |
| 2147 | } |
| 2148 | |
| 2149 | //----------------------------------------------------------------------------- |
| 2150 | // nsHttpHandler::nsISupports |
| 2151 | //----------------------------------------------------------------------------- |
| 2152 | |
| 2153 | NS_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" , 2155); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0" ") (" "illegal refcnt" ")"); do { MOZ_CrashSequence(__null, 2155 ); __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" , 2155); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpHandler\" != nullptr" ") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null , 2155); __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" , 2155); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0" ") (" "dup release" ")"); do { MOZ_CrashSequence(__null, 2155 ); __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" , 2155); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpHandler\" != nullptr" ") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null , 2155); __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" , 2155); 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; } |
| 2154 | 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" , 2155); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0" ") (" "illegal refcnt" ")"); do { MOZ_CrashSequence(__null, 2155 ); __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" , 2155); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpHandler\" != nullptr" ") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null , 2155); __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" , 2155); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0" ") (" "dup release" ")"); do { MOZ_CrashSequence(__null, 2155 ); __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" , 2155); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpHandler\" != nullptr" ") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null , 2155); __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" , 2155); 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; } |
| 2155 | 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" , 2155); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0" ") (" "illegal refcnt" ")"); do { MOZ_CrashSequence(__null, 2155 ); __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" , 2155); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpHandler\" != nullptr" ") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null , 2155); __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" , 2155); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0" ") (" "dup release" ")"); do { MOZ_CrashSequence(__null, 2155 ); __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" , 2155); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpHandler\" != nullptr" ") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null , 2155); __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" , 2155); 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; } |
| 2156 | |
| 2157 | //----------------------------------------------------------------------------- |
| 2158 | // nsHttpHandler::nsIProtocolHandler |
| 2159 | //----------------------------------------------------------------------------- |
| 2160 | |
| 2161 | NS_IMETHODIMPnsresult |
| 2162 | nsHttpHandler::GetScheme(nsACString& aScheme) { |
| 2163 | aScheme.AssignLiteral("http"); |
| 2164 | return NS_OK; |
| 2165 | } |
| 2166 | |
| 2167 | NS_IMETHODIMPnsresult |
| 2168 | nsHttpHandler::NewChannel(nsIURI* uri, nsILoadInfo* aLoadInfo, |
| 2169 | nsIChannel** result) { |
| 2170 | 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); |
| 2171 | |
| 2172 | 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" , 2172); return NS_ERROR_INVALID_POINTER; } } while (false); |
| 2173 | 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" , 2173); return NS_ERROR_INVALID_POINTER; } } while (false); |
| 2174 | |
| 2175 | // Verify that we have been given a valid scheme |
| 2176 | if (!net::SchemeIsHttpOrHttps(uri)) { |
| 2177 | NS_WARNING("Invalid URI scheme")NS_DebugBreak(NS_DEBUG_WARNING, "Invalid URI scheme", nullptr , "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp" , 2177); |
| 2178 | return NS_ERROR_UNEXPECTED; |
| 2179 | } |
| 2180 | |
| 2181 | return NewProxiedChannel(uri, nullptr, 0, nullptr, aLoadInfo, result); |
| 2182 | } |
| 2183 | |
| 2184 | NS_IMETHODIMPnsresult |
| 2185 | nsHttpHandler::AllowPort(int32_t port, const char* scheme, bool* _retval) { |
| 2186 | // don't override anything. |
| 2187 | *_retval = false; |
| 2188 | return NS_OK; |
| 2189 | } |
| 2190 | |
| 2191 | //----------------------------------------------------------------------------- |
| 2192 | // nsHttpHandler::nsIProxiedProtocolHandler |
| 2193 | //----------------------------------------------------------------------------- |
| 2194 | |
| 2195 | nsresult nsHttpHandler::SetupChannelInternal( |
| 2196 | HttpBaseChannel* aChannel, nsIURI* uri, nsIProxyInfo* givenProxyInfo, |
| 2197 | uint32_t proxyResolveFlags, nsIURI* proxyURI, nsILoadInfo* aLoadInfo, |
| 2198 | nsIChannel** result) { |
| 2199 | RefPtr<HttpBaseChannel> httpChannel = aChannel; |
| 2200 | |
| 2201 | nsCOMPtr<nsProxyInfo> proxyInfo; |
| 2202 | if (givenProxyInfo) { |
| 2203 | proxyInfo = do_QueryInterface(givenProxyInfo); |
| 2204 | 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" , 2204); return NS_ERROR_INVALID_ARG; } } while (false); |
| 2205 | } |
| 2206 | |
| 2207 | uint32_t caps = mCapabilities; |
| 2208 | |
| 2209 | uint64_t channelId = NewChannelId(); |
| 2210 | nsresult rv = httpChannel->Init(uri, caps, proxyInfo, proxyResolveFlags, |
| 2211 | proxyURI, channelId, aLoadInfo); |
| 2212 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv; |
| 2213 | |
| 2214 | httpChannel.forget(result); |
| 2215 | return NS_OK; |
| 2216 | } |
| 2217 | |
| 2218 | NS_IMETHODIMPnsresult |
| 2219 | nsHttpHandler::NewProxiedChannel(nsIURI* uri, nsIProxyInfo* givenProxyInfo, |
| 2220 | uint32_t proxyResolveFlags, nsIURI* proxyURI, |
| 2221 | nsILoadInfo* aLoadInfo, nsIChannel** result) { |
| 2222 | HttpBaseChannel* httpChannel; |
| 2223 | |
| 2224 | 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); |
| 2225 | |
| 2226 | if (IsNeckoChild()) { |
| 2227 | httpChannel = new HttpChannelChild(); |
| 2228 | } else { |
| 2229 | // HACK: make sure PSM gets initialized on the main thread. |
| 2230 | net_EnsurePSMInit(); |
| 2231 | httpChannel = new nsHttpChannel(); |
| 2232 | } |
| 2233 | |
| 2234 | return SetupChannelInternal(httpChannel, uri, givenProxyInfo, |
| 2235 | proxyResolveFlags, proxyURI, aLoadInfo, result); |
| 2236 | } |
| 2237 | |
| 2238 | nsresult nsHttpHandler::CreateTRRServiceChannel( |
| 2239 | nsIURI* uri, nsIProxyInfo* givenProxyInfo, uint32_t proxyResolveFlags, |
| 2240 | nsIURI* proxyURI, nsILoadInfo* aLoadInfo, nsIChannel** result) { |
| 2241 | HttpBaseChannel* httpChannel = new TRRServiceChannel(); |
| 2242 | |
| 2243 | 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) |
| 2244 | 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); |
| 2245 | |
| 2246 | return SetupChannelInternal(httpChannel, uri, givenProxyInfo, |
| 2247 | proxyResolveFlags, proxyURI, aLoadInfo, result); |
| 2248 | } |
| 2249 | |
| 2250 | //----------------------------------------------------------------------------- |
| 2251 | // nsHttpHandler::nsIHttpProtocolHandler |
| 2252 | //----------------------------------------------------------------------------- |
| 2253 | |
| 2254 | NS_IMETHODIMPnsresult |
| 2255 | nsHttpHandler::GetUserAgent(nsACString& value) { |
| 2256 | value = UserAgent(false); |
| 2257 | return NS_OK; |
| 2258 | } |
| 2259 | |
| 2260 | NS_IMETHODIMPnsresult |
| 2261 | nsHttpHandler::GetRfpUserAgent(nsACString& value) { |
| 2262 | value = UserAgent(true); |
| 2263 | return NS_OK; |
| 2264 | } |
| 2265 | |
| 2266 | NS_IMETHODIMPnsresult |
| 2267 | nsHttpHandler::GetDocumentAcceptHeader(nsACString& value) { |
| 2268 | value = mDocumentAcceptHeader; |
| 2269 | return NS_OK; |
| 2270 | } |
| 2271 | |
| 2272 | NS_IMETHODIMPnsresult |
| 2273 | nsHttpHandler::GetAppName(nsACString& value) { |
| 2274 | value = mLegacyAppName; |
| 2275 | return NS_OK; |
| 2276 | } |
| 2277 | |
| 2278 | NS_IMETHODIMPnsresult |
| 2279 | nsHttpHandler::GetAppVersion(nsACString& value) { |
| 2280 | value = mLegacyAppVersion; |
| 2281 | return NS_OK; |
| 2282 | } |
| 2283 | |
| 2284 | NS_IMETHODIMPnsresult |
| 2285 | nsHttpHandler::GetPlatform(nsACString& value) { |
| 2286 | value = mPlatform; |
| 2287 | return NS_OK; |
| 2288 | } |
| 2289 | |
| 2290 | NS_IMETHODIMPnsresult |
| 2291 | nsHttpHandler::GetOscpu(nsACString& value) { |
| 2292 | value = mOscpu; |
| 2293 | return NS_OK; |
| 2294 | } |
| 2295 | |
| 2296 | NS_IMETHODIMPnsresult |
| 2297 | nsHttpHandler::GetMisc(nsACString& value) { |
| 2298 | value = mMisc; |
| 2299 | return NS_OK; |
| 2300 | } |
| 2301 | |
| 2302 | NS_IMETHODIMPnsresult |
| 2303 | nsHttpHandler::GetAltSvcCacheKeys(nsTArray<nsCString>& value) { |
| 2304 | return mAltSvcCache->GetAltSvcCacheKeys(value); |
| 2305 | } |
| 2306 | |
| 2307 | NS_IMETHODIMPnsresult |
| 2308 | nsHttpHandler::GetAuthCacheKeys(nsTArray<nsCString>& aValues) { |
| 2309 | mAuthCache->CollectKeys(aValues); |
| 2310 | mPrivateAuthCache->CollectKeys(aValues); |
| 2311 | return NS_OK; |
| 2312 | } |
| 2313 | |
| 2314 | //----------------------------------------------------------------------------- |
| 2315 | // nsHttpHandler::nsIObserver |
| 2316 | //----------------------------------------------------------------------------- |
| 2317 | |
| 2318 | NS_IMETHODIMPnsresult |
| 2319 | nsHttpHandler::Observe(nsISupports* subject, const char* topic, |
| 2320 | const char16_t* data) { |
| 2321 | 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" , 2321); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { MOZ_CrashSequence(__null, 2321); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 2322 | 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); |
| 2323 | |
| 2324 | nsresult rv; |
| 2325 | if (!strcmp(topic, "profile-change-net-teardown") || |
| 2326 | !strcmp(topic, NS_XPCOM_SHUTDOWN_OBSERVER_ID"xpcom-shutdown")) { |
| 2327 | mHandlerActive = false; |
| 2328 | |
| 2329 | // clear cache of all authentication credentials. |
| 2330 | mAuthCache->ClearAll(); |
| 2331 | mPrivateAuthCache->ClearAll(); |
| 2332 | if (mWifiTickler) mWifiTickler->Cancel(); |
| 2333 | |
| 2334 | // Inform nsIOService that network is tearing down. |
| 2335 | gIOService->SetHttpHandlerAlreadyShutingDown(); |
| 2336 | |
| 2337 | ShutdownConnectionManager(); |
| 2338 | |
| 2339 | // need to reset the session start time since cache validation may |
| 2340 | // depend on this value. |
| 2341 | mSessionStartTime = NowInSeconds()PRTimeToSeconds(PR_Now()); |
| 2342 | |
| 2343 | // Since nsHttpHandler::Observe() is also called in socket process, we don't |
| 2344 | // want to do telemetry twice. |
| 2345 | if (XRE_IsParentProcess()) { |
| 2346 | if (!StaticPrefs::privacy_donottrackheader_enabled()) { |
| 2347 | glean::http::dnt_usage.AccumulateSingleSample(2); |
| 2348 | } else { |
| 2349 | glean::http::dnt_usage.AccumulateSingleSample(1); |
| 2350 | } |
| 2351 | } |
| 2352 | |
| 2353 | mActivityDistributor = nullptr; |
| 2354 | } else if (!strcmp(topic, "profile-change-net-restore")) { |
| 2355 | // initialize connection manager |
| 2356 | rv = InitConnectionMgr(); |
| 2357 | 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" , 2357); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))" ")"); do { MOZ_CrashSequence(__null, 2357); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 2358 | mAltSvcCache = MakeUnique<AltSvcCache>(); |
| 2359 | } else if (!strcmp(topic, "net:clear-active-logins")) { |
| 2360 | mAuthCache->ClearAll(); |
| 2361 | mPrivateAuthCache->ClearAll(); |
| 2362 | } else if (!strcmp(topic, "net:cancel-all-connections")) { |
| 2363 | if (mConnMgr) { |
| 2364 | mConnMgr->AbortAndCloseAllConnections(0, nullptr); |
| 2365 | } |
| 2366 | } else if (!strcmp(topic, "net:prune-dead-connections")) { |
| 2367 | if (mConnMgr) { |
| 2368 | rv = mConnMgr->PruneDeadConnections(); |
| 2369 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 2370 | 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) |
| 2371 | 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); |
| 2372 | } |
| 2373 | } |
| 2374 | } else if (!strcmp(topic, "net:prune-all-connections")) { |
| 2375 | if (mConnMgr) { |
| 2376 | rv = mConnMgr->DoShiftReloadConnectionCleanup(); |
| 2377 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 2378 | 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) |
| 2379 | 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); |
| 2380 | } |
| 2381 | rv = mConnMgr->PruneDeadConnections(); |
| 2382 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 2383 | 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) |
| 2384 | 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); |
| 2385 | } |
| 2386 | } |
| 2387 | #if 0 |
| 2388 | } else if (!strcmp(topic, "net:failed-to-process-uri-content")) { |
| 2389 | // nop right now - we used to cancel h1 pipelines based on this, |
| 2390 | // but those are no longer implemented |
| 2391 | nsCOMPtr<nsIURI> uri = do_QueryInterface(subject); |
| 2392 | #endif |
| 2393 | } else if (!strcmp(topic, "last-pb-context-exited")) { |
| 2394 | mPrivateAuthCache->ClearAll(); |
| 2395 | if (mAltSvcCache) { |
| 2396 | mAltSvcCache->ClearAltServiceMappings(); |
| 2397 | } |
| 2398 | nsCORSListenerProxy::ClearPrivateBrowsingCache(); |
| 2399 | } else if (!strcmp(topic, "browser:purge-session-history")) { |
| 2400 | if (mConnMgr) { |
| 2401 | (void)mConnMgr->ClearConnectionHistory(); |
| 2402 | } |
| 2403 | if (mAltSvcCache) { |
| 2404 | mAltSvcCache->ClearAltServiceMappings(); |
| 2405 | } |
| 2406 | } else if (!strcmp(topic, NS_NETWORK_LINK_TOPIC"network:link-status-changed")) { |
| 2407 | if (mConnMgr) { |
| 2408 | rv = mConnMgr->PruneDeadConnections(); |
| 2409 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 2410 | 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) |
| 2411 | 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); |
| 2412 | } |
| 2413 | rv = mConnMgr->VerifyTraffic(); |
| 2414 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 2415 | 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); |
| 2416 | } |
| 2417 | // We exclude HTTP/3 for an origin when any error occurs during |
| 2418 | // connection establishment. A common error is caused by UDP being blocked |
| 2419 | // by the network. When the network changes, it’s likely that UDP is no |
| 2420 | // longer blocked, so we should reset the exclusion list to give HTTP/3 |
| 2421 | // another chance. |
| 2422 | MutexAutoLock lock(mHttpExclusionLock); |
| 2423 | mExcludedHttp3Origins.Clear(); |
| 2424 | } |
| 2425 | } else if (!strcmp(topic, "application-background")) { |
| 2426 | // going to the background on android means we should close |
| 2427 | // down idle connections for power conservation |
| 2428 | if (mConnMgr) { |
| 2429 | rv = mConnMgr->DoShiftReloadConnectionCleanup(); |
| 2430 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 2431 | 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) |
| 2432 | 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); |
| 2433 | } |
| 2434 | } |
| 2435 | } else if (!strcmp(topic, "net:current-browser-id")) { |
| 2436 | // The window id will be updated by HttpConnectionMgrParent. |
| 2437 | if (XRE_IsParentProcess()) { |
| 2438 | nsCOMPtr<nsISupportsPRUint64> wrapper = do_QueryInterface(subject); |
| 2439 | 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" , 2439); AnnotateMozCrashReason("MOZ_RELEASE_ASSERT" "(" "wrapper" ")"); do { MOZ_CrashSequence(__null, 2439); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 2440 | |
| 2441 | uint64_t id = 0; |
| 2442 | wrapper->GetData(&id); |
| 2443 | 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" , 2443); AnnotateMozCrashReason("MOZ_ASSERT" "(" "id" ")"); do { MOZ_CrashSequence(__null, 2443); __attribute__((nomerge)) :: abort(); } while (false); } } while (false); |
| 2444 | |
| 2445 | static uint64_t sCurrentBrowserId = 0; |
| 2446 | if (sCurrentBrowserId != id) { |
| 2447 | sCurrentBrowserId = id; |
| 2448 | if (mConnMgr) { |
| 2449 | mConnMgr->UpdateCurrentBrowserId(sCurrentBrowserId); |
| 2450 | } |
| 2451 | } |
| 2452 | } |
| 2453 | } else if (!strcmp(topic, "intl:app-locales-changed")) { |
| 2454 | // If the locale changed, there's a chance the accept language did too |
| 2455 | mAcceptLanguagesIsDirty = true; |
| 2456 | } else if (!strcmp(topic, "network:reset-http3-excluded-list")) { |
| 2457 | MutexAutoLock lock(mHttpExclusionLock); |
| 2458 | mExcludedHttp3Origins.Clear(); |
| 2459 | } else if (!strcmp(topic, "network:socket-process-crashed")) { |
| 2460 | ShutdownConnectionManager(); |
| 2461 | mConnMgr = nullptr; |
| 2462 | (void)InitConnectionMgr(); |
| 2463 | } else if (!strcmp(topic, "idle-daily")) { |
| 2464 | // Submit the local-network-access ping once per day |
| 2465 | if (XRE_IsParentProcess()) { |
| 2466 | #if defined(EARLY_BETA_OR_EARLIER1) // Submit custom telemetry ping. |
| 2467 | glean_pings::LocalNetworkAccess.Submit(); |
| 2468 | #endif |
| 2469 | } |
| 2470 | } |
| 2471 | return NS_OK; |
| 2472 | } |
| 2473 | |
| 2474 | // nsISpeculativeConnect |
| 2475 | |
| 2476 | nsresult nsHttpHandler::SpeculativeConnectInternal( |
| 2477 | nsIURI* aURI, nsIPrincipal* aPrincipal, |
| 2478 | Maybe<OriginAttributes>&& aOriginAttributes, |
| 2479 | nsIInterfaceRequestor* aCallbacks, bool anonymous) { |
| 2480 | if (IsNeckoChild()) { |
| 2481 | nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(aCallbacks); |
| 2482 | |
| 2483 | gNeckoChild->SendSpeculativeConnect( |
| 2484 | nullptr, IPC::SerializedLoadContext(loadContext), aURI, aPrincipal, |
| 2485 | std::move(aOriginAttributes), anonymous); |
| 2486 | return NS_OK; |
| 2487 | } |
| 2488 | |
| 2489 | if (!mHandlerActive) return NS_OK; |
| 2490 | |
| 2491 | 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" , 2491); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { MOZ_CrashSequence(__null, 2491); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 2492 | |
| 2493 | nsISiteSecurityService* sss = gHttpHandler->GetSSService(); |
| 2494 | bool isStsHost = false; |
| 2495 | if (!sss) return NS_OK; |
| 2496 | |
| 2497 | nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(aCallbacks); |
| 2498 | OriginAttributes originAttributes; |
| 2499 | // If the principal is given, we use the originAttributes from this |
| 2500 | // principal. Otherwise, we use the originAttributes from the loadContext. |
| 2501 | if (aOriginAttributes) { |
| 2502 | originAttributes = std::move(aOriginAttributes.ref()); |
| 2503 | } else if (aPrincipal) { |
| 2504 | originAttributes = aPrincipal->OriginAttributesRef(); |
| 2505 | } else if (loadContext) { |
| 2506 | loadContext->GetOriginAttributes(originAttributes); |
| 2507 | } |
| 2508 | |
| 2509 | nsCOMPtr<nsIURI> clone; |
| 2510 | if (NS_SUCCEEDED(sss->IsSecureURI(aURI, originAttributes, &isStsHost))((bool)(__builtin_expect(!!(!NS_FAILED_impl(sss->IsSecureURI (aURI, originAttributes, &isStsHost))), 1))) && |
| 2511 | isStsHost) { |
| 2512 | if (NS_SUCCEEDED(NS_GetSecureUpgradedURI(aURI, getter_AddRefs(clone)))((bool)(__builtin_expect(!!(!NS_FAILED_impl(NS_GetSecureUpgradedURI (aURI, getter_AddRefs(clone)))), 1)))) { |
| 2513 | aURI = clone.get(); |
| 2514 | // (NOTE: We better make sure |clone| stays alive until the end |
| 2515 | // of the function now, since our aURI arg now points to it!) |
| 2516 | } |
| 2517 | } |
| 2518 | |
| 2519 | if (!aOriginAttributes) { |
| 2520 | // We must update the originAttributes with the network state first party |
| 2521 | // domain **after** we upgrade aURI to https. |
| 2522 | // Otherwise the speculative connection will be keyed by a http URL |
| 2523 | // and end up not being used. |
| 2524 | StoragePrincipalHelper::UpdateOriginAttributesForNetworkState( |
| 2525 | aURI, originAttributes); |
| 2526 | } |
| 2527 | |
| 2528 | nsAutoCString scheme; |
| 2529 | nsresult rv = aURI->GetScheme(scheme); |
| 2530 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv; |
| 2531 | |
| 2532 | // If this is HTTPS, make sure PSM is initialized as the channel |
| 2533 | // creation path may have been bypassed |
| 2534 | if (scheme.EqualsLiteral("https")) { |
| 2535 | if (!IsNeckoChild()) { |
| 2536 | // make sure PSM gets initialized on the main thread. |
| 2537 | net_EnsurePSMInit(); |
| 2538 | } |
| 2539 | } |
| 2540 | // Ensure that this is HTTP or HTTPS, otherwise we don't do preconnect here |
| 2541 | else if (!scheme.EqualsLiteral("http")) { |
| 2542 | return NS_ERROR_UNEXPECTED; |
| 2543 | } |
| 2544 | |
| 2545 | nsAutoCString host; |
| 2546 | rv = aURI->GetAsciiHost(host); |
| 2547 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv; |
| 2548 | |
| 2549 | int32_t port = -1; |
| 2550 | rv = aURI->GetPort(&port); |
| 2551 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) return rv; |
| 2552 | |
| 2553 | nsAutoCString username; |
| 2554 | aURI->GetUsername(username); |
| 2555 | |
| 2556 | RefPtr<AltSvcMapping> mapping; |
| 2557 | if (username.IsEmpty()) { |
| 2558 | mapping = gHttpHandler->GetAltServiceMapping( |
| 2559 | scheme, host, port, originAttributes.IsPrivateBrowsing(), |
| 2560 | originAttributes, true, true); |
| 2561 | } |
| 2562 | |
| 2563 | RefPtr<nsHttpConnectionInfo> ci; |
| 2564 | if (mapping) { |
| 2565 | mapping->GetConnectionInfo(getter_AddRefs(ci), nullptr, originAttributes); |
| 2566 | } else { |
| 2567 | ci = new nsHttpConnectionInfo(host, port, ""_ns, username, nullptr, |
| 2568 | originAttributes, aURI->SchemeIs("https")); |
| 2569 | } |
| 2570 | ci->SetAnonymous(anonymous); |
| 2571 | if (originAttributes.IsPrivateBrowsing()) { |
| 2572 | ci->SetPrivate(true); |
| 2573 | } |
| 2574 | |
| 2575 | if (mDebugObservations) { |
| 2576 | // this is basically used for test coverage of an otherwise 'hintable' |
| 2577 | // feature |
| 2578 | |
| 2579 | nsCOMPtr<nsIObserverService> obsService = services::GetObserverService(); |
| 2580 | if (obsService) { |
| 2581 | // This is used to test if the speculative connection has the right |
| 2582 | // connection info. |
| 2583 | nsPrintfCString debugHashKey("%s", ci->HashKey().get()); |
| 2584 | obsService->NotifyObservers(nullptr, "speculative-connect-request", |
| 2585 | NS_ConvertUTF8toUTF16(debugHashKey).get()); |
| 2586 | for (auto* cp : |
| 2587 | dom::ContentParent::AllProcesses(dom::ContentParent::eLive)) { |
| 2588 | PNeckoParent* neckoParent = |
| 2589 | SingleManagedOrNull(cp->ManagedPNeckoParent()); |
| 2590 | if (!neckoParent) { |
| 2591 | continue; |
| 2592 | } |
| 2593 | (void)neckoParent->SendSpeculativeConnectRequest(); |
| 2594 | } |
| 2595 | } |
| 2596 | } |
| 2597 | |
| 2598 | bool fetchHTTPSRR = EchConfigEnabled(); |
| 2599 | if (StaticPrefs::network_http_happy_eyeballs_enabled()) { |
| 2600 | ci->SetHappyEyeballsEnabled(true); |
| 2601 | // When HE is enabled, HTTPS RR lookups are handled by |
| 2602 | // HappyEyeballsConnectionAttempt. |
| 2603 | fetchHTTPSRR = false; |
| 2604 | } |
| 2605 | |
| 2606 | 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); |
| 2607 | // When ech is enabled, always do speculative connect with HTTPS RR. |
| 2608 | return MaybeSpeculativeConnectWithHTTPSRR(ci, aCallbacks, 0, fetchHTTPSRR); |
| 2609 | } |
| 2610 | |
| 2611 | nsresult nsHttpHandler::SpeculativeConnect(nsHttpConnectionInfo* ci, |
| 2612 | nsIInterfaceRequestor* callbacks, |
| 2613 | uint32_t caps, |
| 2614 | SpeculativeTransaction* aTrans) { |
| 2615 | if (mDebugObservations) { |
| 2616 | nsCOMPtr<nsIObserverService> obsService = services::GetObserverService(); |
| 2617 | if (obsService) { |
| 2618 | nsPrintfCString debugHashKey("%s", ci->HashKey().get()); |
| 2619 | obsService->NotifyObservers(nullptr, "speculative-connect-request", |
| 2620 | NS_ConvertUTF8toUTF16(debugHashKey).get()); |
| 2621 | } |
| 2622 | } |
| 2623 | RefPtr<nsHttpConnectionInfo> clone = ci->Clone(); |
| 2624 | return mConnMgr->SpeculativeConnect(clone, callbacks, caps, aTrans); |
| 2625 | } |
| 2626 | |
| 2627 | NS_IMETHODIMPnsresult |
| 2628 | nsHttpHandler::SpeculativeConnect(nsIURI* aURI, nsIPrincipal* aPrincipal, |
| 2629 | nsIInterfaceRequestor* aCallbacks, |
| 2630 | bool aAnonymous) { |
| 2631 | return SpeculativeConnectInternal(aURI, aPrincipal, Nothing(), aCallbacks, |
| 2632 | aAnonymous); |
| 2633 | } |
| 2634 | |
| 2635 | NS_IMETHODIMPnsresult nsHttpHandler::SpeculativeConnectWithOriginAttributes( |
| 2636 | nsIURI* aURI, JS::Handle<JS::Value> aOriginAttributes, |
| 2637 | nsIInterfaceRequestor* aCallbacks, bool aAnonymous, JSContext* aCx) { |
| 2638 | OriginAttributes attrs; |
| 2639 | if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) { |
| 2640 | return NS_ERROR_INVALID_ARG; |
| 2641 | } |
| 2642 | |
| 2643 | SpeculativeConnectWithOriginAttributesNative(aURI, std::move(attrs), |
| 2644 | aCallbacks, aAnonymous); |
| 2645 | return NS_OK; |
| 2646 | } |
| 2647 | |
| 2648 | NS_IMETHODIMP_(void)void |
| 2649 | nsHttpHandler::SpeculativeConnectWithOriginAttributesNative( |
| 2650 | nsIURI* aURI, OriginAttributes&& aOriginAttributes, |
| 2651 | nsIInterfaceRequestor* aCallbacks, bool aAnonymous) { |
| 2652 | Maybe<OriginAttributes> originAttributes; |
| 2653 | originAttributes.emplace(aOriginAttributes); |
| 2654 | (void)SpeculativeConnectInternal(aURI, nullptr, std::move(originAttributes), |
| 2655 | aCallbacks, aAnonymous); |
| 2656 | } |
| 2657 | |
| 2658 | void nsHttpHandler::TickleWifi(nsIInterfaceRequestor* cb) { |
| 2659 | if (!cb || !mWifiTickler) return; |
| 2660 | |
| 2661 | // If B2G requires a similar mechanism nsINetworkManager, currently only avail |
| 2662 | // on B2G, contains the necessary information on wifi and gateway |
| 2663 | |
| 2664 | nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(cb); |
| 2665 | nsCOMPtr<nsPIDOMWindowOuter> piWindow = do_QueryInterface(domWindow); |
| 2666 | if (!piWindow) return; |
| 2667 | |
| 2668 | RefPtr<dom::Navigator> navigator = piWindow->GetNavigator(); |
| 2669 | if (!navigator) return; |
| 2670 | |
| 2671 | RefPtr<dom::network::Connection> networkProperties = |
| 2672 | navigator->GetConnection(IgnoreErrors()); |
| 2673 | if (!networkProperties) return; |
| 2674 | |
| 2675 | uint32_t gwAddress = networkProperties->GetDhcpGateway(); |
| 2676 | bool isWifi = networkProperties->GetIsWifi(); |
| 2677 | if (!gwAddress || !isWifi) return; |
| 2678 | |
| 2679 | mWifiTickler->SetIPV4Address(gwAddress); |
| 2680 | mWifiTickler->Tickle(); |
| 2681 | } |
| 2682 | |
| 2683 | //----------------------------------------------------------------------------- |
| 2684 | // nsHttpsHandler implementation |
| 2685 | //----------------------------------------------------------------------------- |
| 2686 | |
| 2687 | NS_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" , 2689); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0" ") (" "illegal refcnt" ")"); do { MOZ_CrashSequence(__null, 2689 ); __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" , 2689); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpsHandler\" != nullptr" ") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null , 2689); __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" , 2689); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0" ") (" "dup release" ")"); do { MOZ_CrashSequence(__null, 2689 ); __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" , 2689); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpsHandler\" != nullptr" ") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null , 2689); __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" , 2689); 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; } |
| 2688 | 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" , 2689); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0" ") (" "illegal refcnt" ")"); do { MOZ_CrashSequence(__null, 2689 ); __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" , 2689); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpsHandler\" != nullptr" ") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null , 2689); __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" , 2689); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0" ") (" "dup release" ")"); do { MOZ_CrashSequence(__null, 2689 ); __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" , 2689); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpsHandler\" != nullptr" ") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null , 2689); __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" , 2689); 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; } |
| 2689 | 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" , 2689); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) >= 0" ") (" "illegal refcnt" ")"); do { MOZ_CrashSequence(__null, 2689 ); __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" , 2689); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpsHandler\" != nullptr" ") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null , 2689); __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" , 2689); AnnotateMozCrashReason("MOZ_ASSERT" "(" "int32_t(mRefCnt) > 0" ") (" "dup release" ")"); do { MOZ_CrashSequence(__null, 2689 ); __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" , 2689); AnnotateMozCrashReason("MOZ_ASSERT" "(" "\"nsHttpsHandler\" != nullptr" ") (" "Must specify a name" ")"); do { MOZ_CrashSequence(__null , 2689); __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" , 2689); 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; } |
| 2690 | |
| 2691 | nsresult nsHttpsHandler::Init() { |
| 2692 | nsCOMPtr<nsIProtocolHandler> httpHandler( |
| 2693 | do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX"@mozilla.org/network/protocol;1?name=" "http")); |
| 2694 | 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" , 2694); AnnotateMozCrashReason("MOZ_ASSERT" "(" "httpHandler.get() != nullptr" ")"); do { MOZ_CrashSequence(__null, 2694); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 2695 | return NS_OK; |
| 2696 | } |
| 2697 | |
| 2698 | NS_IMETHODIMPnsresult |
| 2699 | nsHttpsHandler::GetScheme(nsACString& aScheme) { |
| 2700 | aScheme.AssignLiteral("https"); |
| 2701 | return NS_OK; |
| 2702 | } |
| 2703 | |
| 2704 | NS_IMETHODIMPnsresult |
| 2705 | nsHttpsHandler::NewChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo, |
| 2706 | nsIChannel** _retval) { |
| 2707 | 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" , 2707); AnnotateMozCrashReason("MOZ_ASSERT" "(" "gHttpHandler" ")"); do { MOZ_CrashSequence(__null, 2707); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 2708 | if (!gHttpHandler) return NS_ERROR_UNEXPECTED; |
| 2709 | return gHttpHandler->NewChannel(aURI, aLoadInfo, _retval); |
| 2710 | } |
| 2711 | |
| 2712 | NS_IMETHODIMPnsresult |
| 2713 | nsHttpsHandler::AllowPort(int32_t aPort, const char* aScheme, bool* _retval) { |
| 2714 | // don't override anything. |
| 2715 | *_retval = false; |
| 2716 | return NS_OK; |
| 2717 | } |
| 2718 | |
| 2719 | NS_IMETHODIMPnsresult |
| 2720 | nsHttpHandler::EnsureHSTSDataReadyNative( |
| 2721 | RefPtr<mozilla::net::HSTSDataCallbackWrapper> aCallback) { |
| 2722 | 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" , 2722); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { MOZ_CrashSequence(__null, 2722); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 2723 | |
| 2724 | nsCOMPtr<nsIURI> uri; |
| 2725 | nsresult rv = NS_NewURI(getter_AddRefs(uri), "http://example.com"); |
| 2726 | 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" , 2726); return rv; } } while (false); |
| 2727 | |
| 2728 | bool shouldUpgrade = false; |
| 2729 | bool willCallback = false; |
| 2730 | OriginAttributes originAttributes; |
| 2731 | auto func = [callback(aCallback)](bool aResult, nsresult aStatus) { |
| 2732 | callback->DoCallback(aResult); |
| 2733 | }; |
| 2734 | rv = NS_ShouldSecureUpgrade(uri, nullptr, nullptr, false, originAttributes, |
| 2735 | shouldUpgrade, std::move(func), willCallback); |
| 2736 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0))) || !willCallback) { |
| 2737 | aCallback->DoCallback(false); |
| 2738 | return rv; |
| 2739 | } |
| 2740 | |
| 2741 | return rv; |
| 2742 | } |
| 2743 | |
| 2744 | NS_IMETHODIMPnsresult |
| 2745 | nsHttpHandler::EnsureHSTSDataReady(JSContext* aCx, Promise** aPromise) { |
| 2746 | if (NS_WARN_IF(!aCx)NS_warn_if_impl(!aCx, "!aCx", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp" , 2746)) { |
| 2747 | return NS_ERROR_FAILURE; |
| 2748 | } |
| 2749 | |
| 2750 | nsIGlobalObject* globalObject = xpc::CurrentNativeGlobal(aCx); |
| 2751 | if (NS_WARN_IF(!globalObject)NS_warn_if_impl(!globalObject, "!globalObject", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp" , 2751)) { |
| 2752 | return NS_ERROR_FAILURE; |
| 2753 | } |
| 2754 | |
| 2755 | ErrorResult result; |
| 2756 | RefPtr<Promise> promise = Promise::Create(globalObject, result); |
| 2757 | if (NS_WARN_IF(result.Failed())NS_warn_if_impl(result.Failed(), "result.Failed()", "/root/firefox-clang/netwerk/protocol/http/nsHttpHandler.cpp" , 2757)) { |
| 2758 | return result.StealNSResult(); |
| 2759 | } |
| 2760 | |
| 2761 | if (IsNeckoChild()) { |
| 2762 | gNeckoChild->SendEnsureHSTSData()->Then( |
| 2763 | GetMainThreadSerialEventTarget(), __func__, |
| 2764 | [promise(promise)]( |
| 2765 | NeckoChild::EnsureHSTSDataPromise::ResolveOrRejectValue&& aResult) { |
| 2766 | if (aResult.IsResolve()) { |
| 2767 | promise->MaybeResolve(aResult.ResolveValue()); |
| 2768 | } else { |
| 2769 | promise->MaybeReject(NS_ERROR_FAILURE); |
| 2770 | } |
| 2771 | }); |
| 2772 | promise.forget(aPromise); |
| 2773 | return NS_OK; |
| 2774 | } |
| 2775 | |
| 2776 | auto callback = [promise(promise)](bool aResult) { |
| 2777 | promise->MaybeResolve(aResult); |
| 2778 | }; |
| 2779 | |
| 2780 | RefPtr<HSTSDataCallbackWrapper> wrapper = |
| 2781 | new HSTSDataCallbackWrapper(std::move(callback)); |
| 2782 | promise.forget(aPromise); |
| 2783 | return EnsureHSTSDataReadyNative(wrapper); |
| 2784 | } |
| 2785 | |
| 2786 | NS_IMETHODIMPnsresult |
| 2787 | nsHttpHandler::ClearCORSPreflightCache() { |
| 2788 | nsCORSListenerProxy::ClearCache(); |
| 2789 | return NS_OK; |
| 2790 | } |
| 2791 | |
| 2792 | void nsHttpHandler::ShutdownConnectionManager() { |
| 2793 | // ensure connection manager is shutdown |
| 2794 | if (mConnMgr) { |
| 2795 | nsresult rv = mConnMgr->Shutdown(); |
| 2796 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 2797 | 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 ) |
| 2798 | ("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 ) |
| 2799 | " 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 ); |
| 2800 | } |
| 2801 | } |
| 2802 | } |
| 2803 | |
| 2804 | uint64_t nsHttpHandler::NewChannelId() { |
| 2805 | // channelId is sometimes passed to JavaScript code (e.g. devtools), |
| 2806 | // values should not exceed safe JavaScript integer range (2^53 – 1). |
| 2807 | // Since the uniqueProcessId starts at 0, this should be safe to use |
| 2808 | // unless we create more than 2^22 processes. |
| 2809 | return ((mUniqueProcessId << 31) & 0xFFFFFFFF80000000LL) | mNextChannelId++; |
| 2810 | } |
| 2811 | |
| 2812 | void nsHttpHandler::NotifyActiveTabLoadOptimization() { |
| 2813 | SetLastActiveTabLoadOptimizationHit(TimeStamp::Now()); |
| 2814 | } |
| 2815 | |
| 2816 | TimeStamp nsHttpHandler::GetLastActiveTabLoadOptimizationHit() { |
| 2817 | auto lastTimestamp = mLastActiveTabLoadOptimizationHit.Lock(); |
| 2818 | return *lastTimestamp; |
| 2819 | } |
| 2820 | |
| 2821 | void nsHttpHandler::SetLastActiveTabLoadOptimizationHit(TimeStamp const& when) { |
| 2822 | if (when.IsNull()) { |
| 2823 | return; |
| 2824 | } |
| 2825 | auto lastTimestamp = mLastActiveTabLoadOptimizationHit.Lock(); |
| 2826 | if (lastTimestamp->IsNull() || *lastTimestamp < when) { |
| 2827 | *lastTimestamp = when; |
| 2828 | } |
| 2829 | } |
| 2830 | |
| 2831 | bool nsHttpHandler::IsBeforeLastActiveTabLoadOptimization( |
| 2832 | TimeStamp const& when) { |
| 2833 | auto lastTimestamp = mLastActiveTabLoadOptimizationHit.Lock(); |
| 2834 | return !lastTimestamp->IsNull() && when <= *lastTimestamp; |
| 2835 | } |
| 2836 | |
| 2837 | void nsHttpHandler::ExcludeHttp2OrHttp3Internal( |
| 2838 | const nsHttpConnectionInfo* ci) { |
| 2839 | if (ci->GetHappyEyeballsEnabled()) { |
| 2840 | return; |
| 2841 | } |
| 2842 | 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) |
| 2843 | 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); |
| 2844 | // The excluded list needs to be stayed synced between parent process and |
| 2845 | // socket process, so we send this information to the parent process here. |
| 2846 | if (XRE_IsSocketProcess()) { |
| 2847 | 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" , 2847); AnnotateMozCrashReason("MOZ_ASSERT" "(" "OnSocketThread()" ")"); do { MOZ_CrashSequence(__null, 2847); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 2848 | |
| 2849 | RefPtr<nsHttpConnectionInfo> cinfo = ci->Clone(); |
| 2850 | NS_DispatchToMainThread(NS_NewRunnableFunction( |
| 2851 | "nsHttpHandler::ExcludeHttp2OrHttp3Internal", |
| 2852 | [cinfo{std::move(cinfo)}]() { |
| 2853 | HttpConnectionInfoCloneArgs connInfoArgs; |
| 2854 | nsHttpConnectionInfo::SerializeHttpConnectionInfo(cinfo, |
| 2855 | connInfoArgs); |
| 2856 | (void)SocketProcessChild::GetSingleton()->SendExcludeHttp2OrHttp3( |
| 2857 | connInfoArgs); |
| 2858 | })); |
| 2859 | } |
| 2860 | |
| 2861 | 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" , 2862); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { MOZ_CrashSequence(__null, 2862); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); } } while ( false) |
| 2862 | 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" , 2862); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { MOZ_CrashSequence(__null, 2862); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); } } while ( false); |
| 2863 | 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" , 2863); AnnotateMozCrashReason("MOZ_ASSERT" "(" "OnSocketThread()" ")"); do { MOZ_CrashSequence(__null, 2863); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); } } while ( false); |
| 2864 | |
| 2865 | if (ci->IsHttp3()) { |
| 2866 | { |
| 2867 | MutexAutoLock lock(mHttpExclusionLock); |
| 2868 | mExcludedHttp3Origins.Insert(ci->GetRoutedHost()); |
| 2869 | } |
| 2870 | mConnMgr->ExcludeHttp3(ci); |
| 2871 | } else { |
| 2872 | { |
| 2873 | MutexAutoLock lock(mHttpExclusionLock); |
| 2874 | mExcludedHttp2Origins.Insert(ci->GetOrigin()); |
| 2875 | } |
| 2876 | mConnMgr->ExcludeHttp2(ci); |
| 2877 | } |
| 2878 | } |
| 2879 | |
| 2880 | void nsHttpHandler::ExcludeHttp2(const nsHttpConnectionInfo* ci) { |
| 2881 | ExcludeHttp2OrHttp3Internal(ci); |
| 2882 | } |
| 2883 | |
| 2884 | bool nsHttpHandler::IsHttp2Excluded(const nsHttpConnectionInfo* ci) { |
| 2885 | MutexAutoLock lock(mHttpExclusionLock); |
| 2886 | return mExcludedHttp2Origins.Contains(ci->GetOrigin()); |
| 2887 | } |
| 2888 | |
| 2889 | void nsHttpHandler::ExcludeHttp3(const nsHttpConnectionInfo* ci) { |
| 2890 | // TODO: exclude HTTP/3 for proxy connection properly. |
| 2891 | if (ci->IsHttp3ProxyConnection()) { |
| 2892 | return; |
| 2893 | } |
| 2894 | 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" , 2894); AnnotateMozCrashReason("MOZ_ASSERT" "(" "ci->IsHttp3()" ")"); do { MOZ_CrashSequence(__null, 2894); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 2895 | ExcludeHttp2OrHttp3Internal(ci); |
| 2896 | } |
| 2897 | |
| 2898 | bool nsHttpHandler::IsHttp3Excluded(const nsACString& aRoutedHost) { |
| 2899 | MutexAutoLock lock(mHttpExclusionLock); |
| 2900 | return mExcludedHttp3Origins.Contains(aRoutedHost); |
| 2901 | } |
| 2902 | |
| 2903 | HttpTrafficAnalyzer* nsHttpHandler::GetHttpTrafficAnalyzer() { |
| 2904 | 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" , 2904); AnnotateMozCrashReason("MOZ_ASSERT" "(" "OnSocketThread()" ") (" "not on socket thread" ")"); do { MOZ_CrashSequence(__null , 2904); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); |
| 2905 | |
| 2906 | if (!StaticPrefs::network_traffic_analyzer_enabled()) { |
| 2907 | return nullptr; |
| 2908 | } |
| 2909 | |
| 2910 | return &mHttpTrafficAnalyzer; |
| 2911 | } |
| 2912 | |
| 2913 | bool nsHttpHandler::IsHttp3Enabled() { |
| 2914 | static const uint32_t TLS3_PREF_VALUE = 4; |
| 2915 | |
| 2916 | return StaticPrefs::network_http_http3_enable() && |
| 2917 | (StaticPrefs::security_tls_version_max() >= TLS3_PREF_VALUE); |
| 2918 | } |
| 2919 | |
| 2920 | bool nsHttpHandler::IsHttp3VersionSupported(const nsACString& version) { |
| 2921 | return (StaticPrefs::network_http_http3_support_version1() && |
| 2922 | version.EqualsLiteral("h3")); |
| 2923 | } |
| 2924 | |
| 2925 | bool nsHttpHandler::IsHttp3SupportedByServer( |
| 2926 | nsHttpResponseHead* aResponseHead) { |
| 2927 | if ((aResponseHead->Version() != HttpVersion::v2_0) || |
| 2928 | (aResponseHead->Status() >= 500) || (aResponseHead->Status() == 421)) { |
| 2929 | return false; |
| 2930 | } |
| 2931 | |
| 2932 | nsAutoCString altSvc; |
| 2933 | (void)aResponseHead->GetHeader(nsHttp::Alternate_Service, altSvc); |
| 2934 | if (altSvc.IsEmpty() || !nsHttp::IsReasonableHeaderValue(altSvc)) { |
| 2935 | return false; |
| 2936 | } |
| 2937 | |
| 2938 | return altSvc.Find("h3=") != -1; |
| 2939 | } |
| 2940 | |
| 2941 | nsresult nsHttpHandler::InitiateTransaction(HttpTransactionShell* aTrans, |
| 2942 | int32_t aPriority) { |
| 2943 | return mConnMgr->AddTransaction(aTrans, aPriority); |
| 2944 | } |
| 2945 | nsresult nsHttpHandler::InitiateTransactionWithStickyConn( |
| 2946 | HttpTransactionShell* aTrans, int32_t aPriority, |
| 2947 | HttpTransactionShell* aTransWithStickyConn) { |
| 2948 | return mConnMgr->AddTransactionWithStickyConn(aTrans, aPriority, |
| 2949 | aTransWithStickyConn); |
| 2950 | } |
| 2951 | |
| 2952 | nsresult nsHttpHandler::RescheduleTransaction(HttpTransactionShell* trans, |
| 2953 | int32_t priority) { |
| 2954 | return mConnMgr->RescheduleTransaction(trans, priority); |
| 2955 | } |
| 2956 | |
| 2957 | void nsHttpHandler::UpdateClassOfServiceOnTransaction( |
| 2958 | HttpTransactionShell* trans, const ClassOfService& classOfService) { |
| 2959 | mConnMgr->UpdateClassOfServiceOnTransaction(trans, classOfService); |
| 2960 | } |
| 2961 | |
| 2962 | nsresult nsHttpHandler::CancelTransaction(HttpTransactionShell* trans, |
| 2963 | nsresult reason) { |
| 2964 | return mConnMgr->CancelTransaction(trans, reason); |
| 2965 | } |
| 2966 | |
| 2967 | void nsHttpHandler::AddHttpChannel(uint64_t aId, nsISupports* aChannel) { |
| 2968 | 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" , 2968); AnnotateMozCrashReason("MOZ_ASSERT" "(" "XRE_IsParentProcess()" ")"); do { MOZ_CrashSequence(__null, 2968); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 2969 | 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" , 2969); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { MOZ_CrashSequence(__null, 2969); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 2970 | |
| 2971 | nsWeakPtr channel(do_GetWeakReference(aChannel)); |
| 2972 | mIDToHttpChannelMap.InsertOrUpdate(aId, std::move(channel)); |
| 2973 | } |
| 2974 | |
| 2975 | void nsHttpHandler::RemoveHttpChannel(uint64_t aId) { |
| 2976 | 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" , 2976); AnnotateMozCrashReason("MOZ_ASSERT" "(" "XRE_IsParentProcess()" ")"); do { MOZ_CrashSequence(__null, 2976); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 2977 | if (!NS_IsMainThread()) { |
| 2978 | nsCOMPtr<nsIRunnable> idleRunnable(NewCancelableRunnableMethod<uint64_t>( |
| 2979 | "nsHttpHandler::RemoveHttpChannel", this, |
| 2980 | &nsHttpHandler::RemoveHttpChannel, aId)); |
| 2981 | |
| 2982 | NS_DispatchToMainThreadQueue(do_AddRef(idleRunnable), |
| 2983 | EventQueuePriority::Idle); |
| 2984 | return; |
| 2985 | } |
| 2986 | |
| 2987 | auto entry = mIDToHttpChannelMap.Lookup(aId); |
| 2988 | if (entry) { |
| 2989 | entry.Remove(); |
| 2990 | } |
| 2991 | } |
| 2992 | |
| 2993 | nsWeakPtr nsHttpHandler::GetWeakHttpChannel(uint64_t aId) { |
| 2994 | 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" , 2994); AnnotateMozCrashReason("MOZ_ASSERT" "(" "XRE_IsParentProcess()" ")"); do { MOZ_CrashSequence(__null, 2994); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 2995 | 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" , 2995); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { MOZ_CrashSequence(__null, 2995); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 2996 | |
| 2997 | return mIDToHttpChannelMap.Get(aId); |
| 2998 | } |
| 2999 | |
| 3000 | nsresult nsHttpHandler::CompleteUpgrade( |
| 3001 | HttpTransactionShell* aTrans, nsIHttpUpgradeListener* aUpgradeListener) { |
| 3002 | return mConnMgr->CompleteUpgrade(aTrans, aUpgradeListener); |
| 3003 | } |
| 3004 | |
| 3005 | nsresult nsHttpHandler::DoShiftReloadConnectionCleanupWithConnInfo( |
| 3006 | nsHttpConnectionInfo* aCi) { |
| 3007 | 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" , 3007); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aCi" ")"); do { MOZ_CrashSequence(__null, 3007); __attribute__((nomerge)) :: abort(); } while (false); } } while (false); |
| 3008 | return mConnMgr->DoShiftReloadConnectionCleanupWithConnInfo(aCi); |
| 3009 | } |
| 3010 | |
| 3011 | void nsHttpHandler::ClearHostMapping(nsHttpConnectionInfo* aConnInfo) { |
| 3012 | if (XRE_IsSocketProcess()) { |
| 3013 | AltServiceChild::ClearHostMapping(aConnInfo); |
| 3014 | return; |
| 3015 | } |
| 3016 | |
| 3017 | AltServiceCache()->ClearHostMapping(aConnInfo); |
| 3018 | } |
| 3019 | |
| 3020 | void nsHttpHandler::SetHttpHandlerInitArgs(const HttpHandlerInitArgs& aArgs) { |
| 3021 | 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" , 3021); AnnotateMozCrashReason("MOZ_ASSERT" "(" "XRE_IsSocketProcess()" ")"); do { MOZ_CrashSequence(__null, 3021); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 3022 | mLegacyAppName = aArgs.mLegacyAppName(); |
| 3023 | mLegacyAppVersion = aArgs.mLegacyAppVersion(); |
| 3024 | mPlatform = aArgs.mPlatform(); |
| 3025 | mOscpu = aArgs.mOscpu(); |
| 3026 | mMisc = aArgs.mMisc(); |
| 3027 | mProduct = aArgs.mProduct(); |
| 3028 | mProductSub = aArgs.mProductSub(); |
| 3029 | mAppName = aArgs.mAppName(); |
| 3030 | mAppVersion = aArgs.mAppVersion(); |
| 3031 | mCompatFirefox = aArgs.mCompatFirefox(); |
| 3032 | mCompatDevice = aArgs.mCompatDevice(); |
| 3033 | mDeviceModelId = aArgs.mDeviceModelId(); |
| 3034 | } |
| 3035 | |
| 3036 | void nsHttpHandler::SetDeviceModelId(const nsACString& aModelId) { |
| 3037 | 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" , 3037); AnnotateMozCrashReason("MOZ_ASSERT" "(" "XRE_IsSocketProcess()" ")"); do { MOZ_CrashSequence(__null, 3037); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 3038 | mDeviceModelId = aModelId; |
| 3039 | } |
| 3040 | |
| 3041 | void nsHttpHandler::MaybeAddAltSvcForTesting( |
| 3042 | nsIURI* aUri, const nsACString& aUsername, bool aPrivateBrowsing, |
| 3043 | nsIInterfaceRequestor* aCallbacks, |
| 3044 | const OriginAttributes& aOriginAttributes) { |
| 3045 | if (!IsHttp3Enabled() || mAltSvcMappingTemptativeMap.IsEmpty()) { |
| 3046 | return; |
| 3047 | } |
| 3048 | |
| 3049 | if (!aUri->SchemeIs("https")) { |
| 3050 | // Only set for HTTPS. |
| 3051 | return; |
| 3052 | } |
| 3053 | |
| 3054 | nsAutoCString originHost; |
| 3055 | if (NS_FAILED(aUri->GetAsciiHost(originHost))((bool)(__builtin_expect(!!(NS_FAILED_impl(aUri->GetAsciiHost (originHost))), 0)))) { |
| 3056 | return; |
| 3057 | } |
| 3058 | |
| 3059 | nsCString* map = mAltSvcMappingTemptativeMap.Get(originHost); |
| 3060 | if (map) { |
| 3061 | int32_t originPort = 80; |
| 3062 | aUri->GetPort(&originPort); |
| 3063 | 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(), TPromiseFlatString<char>(*map).get( )); } } while (0) |
| 3064 | originHost.get(), PromiseFlatCString(*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(), TPromiseFlatString<char>(*map).get( )); } } while (0); |
| 3065 | AltSvcMapping::ProcessHeader(*map, nsCString("https"), originHost, |
| 3066 | originPort, aUsername, aPrivateBrowsing, |
| 3067 | aCallbacks, nullptr, 0, aOriginAttributes, |
| 3068 | nullptr, true); |
| 3069 | } |
| 3070 | } |
| 3071 | |
| 3072 | bool nsHttpHandler::EchConfigEnabled(bool aIsHttp3) { |
| 3073 | if (sParentalControlsEnabled) { |
| 3074 | return false; |
| 3075 | } |
| 3076 | |
| 3077 | if (!aIsHttp3) { |
| 3078 | return StaticPrefs::network_dns_echconfig_enabled(); |
| 3079 | } |
| 3080 | |
| 3081 | return StaticPrefs::network_dns_http3_echconfig_enabled(); |
| 3082 | } |
| 3083 | |
| 3084 | bool nsHttpHandler::FallbackToOriginIfConfigsAreECHAndAllFailed() const { |
| 3085 | return StaticPrefs:: |
| 3086 | network_dns_echconfig_fallback_to_origin_when_all_failed(); |
| 3087 | } |
| 3088 | |
| 3089 | void nsHttpHandler::ExcludeHTTPSRRHost(const nsACString& aHost) { |
| 3090 | 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" , 3090); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { MOZ_CrashSequence(__null, 3090); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 3091 | |
| 3092 | mExcludedHostsForHTTPSRRUpgrade.Insert(aHost); |
| 3093 | } |
| 3094 | |
| 3095 | bool nsHttpHandler::IsHostExcludedForHTTPSRR(const nsACString& aHost) { |
| 3096 | 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" , 3096); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { MOZ_CrashSequence(__null, 3096); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 3097 | |
| 3098 | return mExcludedHostsForHTTPSRRUpgrade.Contains(aHost); |
| 3099 | } |
| 3100 | |
| 3101 | #ifdef XP_MACOSX |
| 3102 | bool nsHttpHandler::IsHostMSAuthority(const nsACString& aHost) { |
| 3103 | 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" , 3103); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { MOZ_CrashSequence(__null, 3103); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 3104 | |
| 3105 | return mMSAuthorities.Contains(aHost); |
| 3106 | } |
| 3107 | #endif |
| 3108 | |
| 3109 | void nsHttpHandler::Exclude0RttTcp(const nsHttpConnectionInfo* ci) { |
| 3110 | 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" , 3110); AnnotateMozCrashReason("MOZ_ASSERT" "(" "OnSocketThread()" ")"); do { MOZ_CrashSequence(__null, 3110); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 3111 | |
| 3112 | if (!StaticPrefs::network_http_early_data_disable_on_error() || |
| 3113 | (mExcluded0RttTcpOrigins.Count() >= |
| 3114 | StaticPrefs::network_http_early_data_max_error())) { |
| 3115 | return; |
| 3116 | } |
| 3117 | |
| 3118 | mExcluded0RttTcpOrigins.Insert(ci->GetOrigin()); |
| 3119 | } |
| 3120 | |
| 3121 | bool nsHttpHandler::Is0RttTcpExcluded(const nsHttpConnectionInfo* ci) { |
| 3122 | 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" , 3122); AnnotateMozCrashReason("MOZ_ASSERT" "(" "OnSocketThread()" ")"); do { MOZ_CrashSequence(__null, 3122); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 3123 | if (!StaticPrefs::network_http_early_data_disable_on_error()) { |
| 3124 | return false; |
| 3125 | } |
| 3126 | |
| 3127 | if (mExcluded0RttTcpOrigins.Count() >= |
| 3128 | StaticPrefs::network_http_early_data_max_error()) { |
| 3129 | return true; |
| 3130 | } |
| 3131 | |
| 3132 | return mExcluded0RttTcpOrigins.Contains(ci->GetOrigin()); |
| 3133 | } |
| 3134 | |
| 3135 | bool nsHttpHandler::HttpActivityDistributorActivated() { |
| 3136 | if (!mActivityDistributor) { |
| 3137 | return false; |
| 3138 | } |
| 3139 | |
| 3140 | return mActivityDistributor->Activated(); |
| 3141 | } |
| 3142 | |
| 3143 | void nsHttpHandler::ObserveHttpActivityWithArgs( |
| 3144 | const HttpActivityArgs& aArgs, uint32_t aActivityType, |
| 3145 | uint32_t aActivitySubtype, PRTime aTimestamp, uint64_t aExtraSizeData, |
| 3146 | const nsACString& aExtraStringData) { |
| 3147 | if (!HttpActivityDistributorActivated()) { |
| 3148 | return; |
| 3149 | } |
| 3150 | |
| 3151 | if (aActivitySubtype == NS_HTTP_ACTIVITY_SUBTYPE_PROXY_RESPONSE_HEADERnsIHttpActivityObserver::ACTIVITY_SUBTYPE_PROXY_RESPONSE_HEADER && |
| 3152 | !mActivityDistributor->ObserveProxyResponseEnabled()) { |
| 3153 | return; |
| 3154 | } |
| 3155 | |
| 3156 | if (aActivityType == NS_ACTIVITY_TYPE_HTTP_CONNECTIONnsIHttpActivityObserver::ACTIVITY_TYPE_HTTP_CONNECTION && |
| 3157 | !mActivityDistributor->ObserveConnectionEnabled()) { |
| 3158 | return; |
| 3159 | } |
| 3160 | |
| 3161 | (void)mActivityDistributor->ObserveActivityWithArgs( |
| 3162 | aArgs, aActivityType, aActivitySubtype, aTimestamp, aExtraSizeData, |
| 3163 | aExtraStringData); |
| 3164 | } |
| 3165 | |
| 3166 | } // namespace mozilla::net |