LCOV - code coverage report
Current view: top level - netwerk/protocol/http - nsHttpHandler.h (source / functions) Hit Total Coverage
Test: output.info Lines: 82 148 55.4 %
Date: 2017-07-14 16:53:18 Functions: 50 103 48.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef nsHttpHandler_h__
       7             : #define nsHttpHandler_h__
       8             : 
       9             : #include "nsHttp.h"
      10             : #include "nsHttpAuthCache.h"
      11             : #include "nsHttpConnectionMgr.h"
      12             : #include "ASpdySession.h"
      13             : 
      14             : #include "nsString.h"
      15             : #include "nsCOMPtr.h"
      16             : #include "nsWeakReference.h"
      17             : 
      18             : #include "nsIHttpProtocolHandler.h"
      19             : #include "nsIObserver.h"
      20             : #include "nsISpeculativeConnect.h"
      21             : 
      22             : class nsIHttpChannel;
      23             : class nsIPrefBranch;
      24             : class nsICancelable;
      25             : class nsICookieService;
      26             : class nsIIOService;
      27             : class nsIRequestContextService;
      28             : class nsISiteSecurityService;
      29             : class nsIStreamConverterService;
      30             : 
      31             : 
      32             : namespace mozilla {
      33             : namespace net {
      34             : 
      35             : bool OnSocketThread();
      36             : 
      37             : class ATokenBucketEvent;
      38             : class EventTokenBucket;
      39             : class Tickler;
      40             : class nsHttpConnection;
      41             : class nsHttpConnectionInfo;
      42             : class nsHttpTransaction;
      43             : class AltSvcMapping;
      44             : 
      45             : enum FrameCheckLevel {
      46             :     FRAMECHECK_LAX,
      47             :     FRAMECHECK_BARELY,
      48             :     FRAMECHECK_STRICT
      49             : };
      50             : 
      51             : //-----------------------------------------------------------------------------
      52             : // nsHttpHandler - protocol handler for HTTP and HTTPS
      53             : //-----------------------------------------------------------------------------
      54             : 
      55             : class nsHttpHandler final : public nsIHttpProtocolHandler
      56             :                           , public nsIObserver
      57             :                           , public nsSupportsWeakReference
      58             :                           , public nsISpeculativeConnect
      59             : {
      60             : public:
      61             :     NS_DECL_THREADSAFE_ISUPPORTS
      62             :     NS_DECL_NSIPROTOCOLHANDLER
      63             :     NS_DECL_NSIPROXIEDPROTOCOLHANDLER
      64             :     NS_DECL_NSIHTTPPROTOCOLHANDLER
      65             :     NS_DECL_NSIOBSERVER
      66             :     NS_DECL_NSISPECULATIVECONNECT
      67             : 
      68             :     nsHttpHandler();
      69             : 
      70             :     MOZ_MUST_USE nsresult Init();
      71             :     MOZ_MUST_USE nsresult AddStandardRequestHeaders(nsHttpRequestHead *,
      72             :                                                     bool isSecure);
      73             :     MOZ_MUST_USE nsresult AddConnectionHeader(nsHttpRequestHead *,
      74             :                                               uint32_t capabilities);
      75             :     bool     IsAcceptableEncoding(const char *encoding, bool isSecure);
      76             : 
      77             :     const nsCString& UserAgent();
      78             : 
      79           3 :     nsHttpVersion  HttpVersion()             { return mHttpVersion; }
      80           0 :     nsHttpVersion  ProxyHttpVersion()        { return mProxyHttpVersion; }
      81           3 :     uint8_t        ReferrerLevel()           { return mReferrerLevel; }
      82           3 :     bool           SpoofReferrerSource()     { return mSpoofReferrerSource; }
      83           3 :     bool           HideOnionReferrerSource() { return mHideOnionReferrerSource; }
      84           3 :     uint8_t        ReferrerTrimmingPolicy()  { return mReferrerTrimmingPolicy; }
      85           4 :     uint8_t        ReferrerXOriginTrimmingPolicy() {
      86           4 :         return mReferrerXOriginTrimmingPolicy;
      87             :     }
      88           3 :     uint8_t        ReferrerXOriginPolicy()   { return mReferrerXOriginPolicy; }
      89          10 :     uint8_t        RedirectionLimit()        { return mRedirectionLimit; }
      90           3 :     PRIntervalTime IdleTimeout()             { return mIdleTimeout; }
      91           0 :     PRIntervalTime SpdyTimeout()             { return mSpdyTimeout; }
      92           0 :     PRIntervalTime ResponseTimeout() {
      93           0 :       return mResponseTimeoutEnabled ? mResponseTimeout : 0;
      94             :     }
      95           3 :     PRIntervalTime ResponseTimeoutEnabled()  { return mResponseTimeoutEnabled; }
      96           0 :     uint32_t       NetworkChangedTimeout()   { return mNetworkChangedTimeout; }
      97           0 :     uint16_t       MaxRequestAttempts()      { return mMaxRequestAttempts; }
      98           3 :     const char    *DefaultSocketType()       { return mDefaultSocketType.get(); /* ok to return null */ }
      99           1 :     uint32_t       PhishyUserPassLength()    { return mPhishyUserPassLength; }
     100           3 :     uint8_t        GetQoSBits()              { return mQoSBits; }
     101           3 :     uint16_t       GetIdleSynTimeout()       { return mIdleSynTimeout; }
     102           0 :     bool           FastFallbackToIPv4()      { return mFastFallbackToIPv4; }
     103             :     uint32_t       MaxSocketCount();
     104             :     bool           EnforceAssocReq()         { return mEnforceAssocReq; }
     105             : 
     106           6 :     bool           IsPersistentHttpsCachingEnabled() { return mEnablePersistentHttpsCaching; }
     107           6 :     bool           IsTelemetryEnabled() { return mTelemetryEnabled; }
     108             :     bool           AllowExperiments() { return mTelemetryEnabled && mAllowExperiments; }
     109             : 
     110           6 :     bool           IsSpdyEnabled() { return mEnableSpdy; }
     111           0 :     bool           IsHttp2Enabled() { return mHttp2Enabled; }
     112           0 :     bool           EnforceHttp2TlsProfile() { return mEnforceHttp2TlsProfile; }
     113           3 :     bool           CoalesceSpdy() { return mCoalesceSpdy; }
     114             :     bool           UseSpdyPersistentSettings() { return mSpdyPersistentSettings; }
     115           0 :     uint32_t       SpdySendingChunkSize() { return mSpdySendingChunkSize; }
     116           0 :     uint32_t       SpdySendBufferSize()      { return mSpdySendBufferSize; }
     117           0 :     uint32_t       SpdyPushAllowance()       { return mSpdyPushAllowance; }
     118           0 :     uint32_t       SpdyPullAllowance()       { return mSpdyPullAllowance; }
     119           0 :     uint32_t       DefaultSpdyConcurrent()   { return mDefaultSpdyConcurrent; }
     120           0 :     PRIntervalTime SpdyPingThreshold() { return mSpdyPingThreshold; }
     121           0 :     PRIntervalTime SpdyPingTimeout() { return mSpdyPingTimeout; }
     122           0 :     bool           AllowPush()   { return mAllowPush; }
     123           9 :     bool           AllowAltSvc() { return mEnableAltSvc; }
     124           6 :     bool           AllowAltSvcOE() { return mEnableAltSvcOE; }
     125           0 :     bool           AllowOriginExtension() { return mEnableOriginExtension; }
     126           0 :     uint32_t       ConnectTimeout()  { return mConnectTimeout; }
     127           5 :     uint32_t       ParallelSpeculativeConnectLimit() { return mParallelSpeculativeConnectLimit; }
     128           6 :     bool           CriticalRequestPrioritization() { return mCriticalRequestPrioritization; }
     129           0 :     bool           UseH2Deps() { return mUseH2Deps; }
     130             : 
     131           0 :     uint32_t       MaxConnectionsPerOrigin() { return mMaxPersistentConnectionsPerServer; }
     132           3 :     bool           UseRequestTokenBucket() { return mRequestTokenBucketEnabled; }
     133           0 :     uint16_t       RequestTokenBucketMinParallelism() { return mRequestTokenBucketMinParallelism; }
     134           1 :     uint32_t       RequestTokenBucketHz() { return mRequestTokenBucketHz; }
     135           1 :     uint32_t       RequestTokenBucketBurst() {return mRequestTokenBucketBurst; }
     136             : 
     137           0 :     bool           PromptTempRedirect()      { return mPromptTempRedirect; }
     138           1 :     bool           IsUrgentStartEnabled() { return mUrgentStartEnabled; }
     139             : 
     140             :     // TCP Keepalive configuration values.
     141             : 
     142             :     // Returns true if TCP keepalive should be enabled for short-lived conns.
     143           6 :     bool TCPKeepaliveEnabledForShortLivedConns() {
     144           6 :       return mTCPKeepaliveShortLivedEnabled;
     145             :     }
     146             :     // Return time (secs) that a connection is consider short lived (for TCP
     147             :     // keepalive purposes). After this time, the connection is long-lived.
     148           3 :     int32_t GetTCPKeepaliveShortLivedTime() {
     149           3 :       return mTCPKeepaliveShortLivedTimeS;
     150             :     }
     151             :     // Returns time (secs) before first TCP keepalive probes should be sent;
     152             :     // same time used between successful keepalive probes.
     153           3 :     int32_t GetTCPKeepaliveShortLivedIdleTime() {
     154           3 :       return mTCPKeepaliveShortLivedIdleTimeS;
     155             :     }
     156             : 
     157             :     // Returns true if TCP keepalive should be enabled for long-lived conns.
     158           0 :     bool TCPKeepaliveEnabledForLongLivedConns() {
     159           0 :       return mTCPKeepaliveLongLivedEnabled;
     160             :     }
     161             :     // Returns time (secs) before first TCP keepalive probes should be sent;
     162             :     // same time used between successful keepalive probes.
     163           0 :     int32_t GetTCPKeepaliveLongLivedIdleTime() {
     164           0 :       return mTCPKeepaliveLongLivedIdleTimeS;
     165             :     }
     166             : 
     167           7 :     bool UseFastOpen()
     168             :     {
     169          14 :         return mUseFastOpen && mFastOpenSupported &&
     170          14 :                mFastOpenConsecutiveFailureCounter < mFastOpenConsecutiveFailureLimit;
     171             :     }
     172             :     // If one of tcp connections return PR_NOT_TCP_SOCKET_ERROR while trying
     173             :     // fast open, it means that Fast Open is turned off so we will not try again
     174             :     // until a restart. This is only on Linux.
     175             :     // For windows 10 we can only check whether a version of windows support
     176             :     // Fast Open at run time, so if we get error PR_NOT_IMPLEMENTED_ERROR it
     177             :     // means that Fast Open is not supported and we will set mFastOpenSupported
     178             :     // to false.
     179           0 :     void SetFastOpenNotSupported() { mFastOpenSupported = false; }
     180             : 
     181             :     void IncrementFastOpenConsecutiveFailureCounter();
     182             : 
     183           2 :     void ResetFastOpenConsecutiveFailureCounter()
     184             :     {
     185           2 :         mFastOpenConsecutiveFailureCounter = 0;
     186           2 :     }
     187             : 
     188             :     // returns the HTTP framing check level preference, as controlled with
     189             :     // network.http.enforce-framing.http1 and network.http.enforce-framing.soft
     190           0 :     FrameCheckLevel GetEnforceH1Framing() { return mEnforceH1Framing; }
     191             : 
     192           6 :     nsHttpAuthCache     *AuthCache(bool aPrivate) {
     193           6 :         return aPrivate ? &mPrivateAuthCache : &mAuthCache;
     194             :     }
     195          59 :     nsHttpConnectionMgr *ConnMgr()   { return mConnMgr; }
     196             : 
     197             :     // cache support
     198           1 :     uint32_t GenerateUniqueID() { return ++mLastUniqueID; }
     199           4 :     uint32_t SessionStartTime() { return mSessionStartTime; }
     200             : 
     201             :     //
     202             :     // Connection management methods:
     203             :     //
     204             :     // - the handler only owns idle connections; it does not own active
     205             :     //   connections.
     206             :     //
     207             :     // - the handler keeps a count of active connections to enforce the
     208             :     //   steady-state max-connections pref.
     209             :     //
     210             : 
     211             :     // Called to kick-off a new transaction, by default the transaction
     212             :     // will be put on the pending transaction queue if it cannot be
     213             :     // initiated at this time.  Callable from any thread.
     214           3 :     MOZ_MUST_USE nsresult InitiateTransaction(nsHttpTransaction *trans,
     215             :                                               int32_t priority)
     216             :     {
     217           3 :         return mConnMgr->AddTransaction(trans, priority);
     218             :     }
     219             : 
     220             :     // Called to change the priority of an existing transaction that has
     221             :     // already been initiated.
     222           0 :     MOZ_MUST_USE nsresult RescheduleTransaction(nsHttpTransaction *trans,
     223             :                                                 int32_t priority)
     224             :     {
     225           0 :         return mConnMgr->RescheduleTransaction(trans, priority);
     226             :     }
     227             : 
     228           0 :     void UpdateClassOfServiceOnTransaction(nsHttpTransaction *trans,
     229             :                                            uint32_t classOfService)
     230             :     {
     231           0 :         mConnMgr->UpdateClassOfServiceOnTransaction(trans, classOfService);
     232           0 :     }
     233             : 
     234             :     // Called to cancel a transaction, which may or may not be assigned to
     235             :     // a connection.  Callable from any thread.
     236           0 :     MOZ_MUST_USE nsresult CancelTransaction(nsHttpTransaction *trans,
     237             :                                             nsresult reason)
     238             :     {
     239           0 :         return mConnMgr->CancelTransaction(trans, reason);
     240             :     }
     241             : 
     242             :     // Called when a connection is done processing a transaction.  Callable
     243             :     // from any thread.
     244           3 :     MOZ_MUST_USE nsresult ReclaimConnection(nsHttpConnection *conn)
     245             :     {
     246           3 :         return mConnMgr->ReclaimConnection(conn);
     247             :     }
     248             : 
     249           0 :     MOZ_MUST_USE nsresult ProcessPendingQ(nsHttpConnectionInfo *cinfo)
     250             :     {
     251           0 :         return mConnMgr->ProcessPendingQ(cinfo);
     252             :     }
     253             : 
     254             :     MOZ_MUST_USE nsresult ProcessPendingQ()
     255             :     {
     256             :         return mConnMgr->ProcessPendingQ();
     257             :     }
     258             : 
     259           0 :     MOZ_MUST_USE nsresult GetSocketThreadTarget(nsIEventTarget **target)
     260             :     {
     261           0 :         return mConnMgr->GetSocketThreadTarget(target);
     262             :     }
     263             : 
     264           5 :     MOZ_MUST_USE nsresult SpeculativeConnect(nsHttpConnectionInfo *ci,
     265             :                                              nsIInterfaceRequestor *callbacks,
     266             :                                              uint32_t caps = 0)
     267             :     {
     268           5 :         TickleWifi(callbacks);
     269           5 :         return mConnMgr->SpeculativeConnect(ci, callbacks, caps);
     270             :     }
     271             : 
     272             :     // Alternate Services Maps are main thread only
     273           0 :     void UpdateAltServiceMapping(AltSvcMapping *map,
     274             :                                  nsProxyInfo *proxyInfo,
     275             :                                  nsIInterfaceRequestor *callbacks,
     276             :                                  uint32_t caps,
     277             :                                  const OriginAttributes &originAttributes)
     278             :     {
     279           0 :         mConnMgr->UpdateAltServiceMapping(map, proxyInfo, callbacks, caps,
     280           0 :                                           originAttributes);
     281           0 :     }
     282             : 
     283           6 :     already_AddRefed<AltSvcMapping> GetAltServiceMapping(const nsACString &scheme,
     284             :                                                          const nsACString &host,
     285             :                                                          int32_t port, bool pb,
     286             :                                                          const OriginAttributes &originAttributes)
     287             :     {
     288           6 :         return mConnMgr->GetAltServiceMapping(scheme, host, port, pb, originAttributes);
     289             :     }
     290             : 
     291             :     //
     292             :     // The HTTP handler caches pointers to specific XPCOM services, and
     293             :     // provides the following helper routines for accessing those services:
     294             :     //
     295             :     MOZ_MUST_USE nsresult GetStreamConverterService(nsIStreamConverterService **);
     296             :     MOZ_MUST_USE nsresult GetIOService(nsIIOService** service);
     297             :     nsICookieService * GetCookieService(); // not addrefed
     298             :     nsISiteSecurityService * GetSSService();
     299             : 
     300             :     // callable from socket thread only
     301             :     uint32_t Get32BitsOfPseudoRandom();
     302             : 
     303             :     // Called by the channel synchronously during asyncOpen
     304           9 :     void OnOpeningRequest(nsIHttpChannel *chan)
     305             :     {
     306           9 :         NotifyObservers(chan, NS_HTTP_ON_OPENING_REQUEST_TOPIC);
     307           9 :     }
     308             : 
     309             :     // Called by the channel before writing a request
     310           6 :     void OnModifyRequest(nsIHttpChannel *chan)
     311             :     {
     312           6 :         NotifyObservers(chan, NS_HTTP_ON_MODIFY_REQUEST_TOPIC);
     313           6 :     }
     314             : 
     315             :     // Called by the channel and cached in the loadGroup
     316           1 :     void OnUserAgentRequest(nsIHttpChannel *chan)
     317             :     {
     318           1 :       NotifyObservers(chan, NS_HTTP_ON_USERAGENT_REQUEST_TOPIC);
     319           1 :     }
     320             : 
     321             :     // Called by the channel once headers are available
     322           3 :     void OnExamineResponse(nsIHttpChannel *chan)
     323             :     {
     324           3 :         NotifyObservers(chan, NS_HTTP_ON_EXAMINE_RESPONSE_TOPIC);
     325           3 :     }
     326             : 
     327             :     // Called by the channel once headers have been merged with cached headers
     328           0 :     void OnExamineMergedResponse(nsIHttpChannel *chan)
     329             :     {
     330           0 :         NotifyObservers(chan, NS_HTTP_ON_EXAMINE_MERGED_RESPONSE_TOPIC);
     331           0 :     }
     332             : 
     333             :     // Called by channels before a redirect happens. This notifies both the
     334             :     // channel's and the global redirect observers.
     335             :     MOZ_MUST_USE nsresult AsyncOnChannelRedirect(
     336             :                               nsIChannel* oldChan,
     337             :                               nsIChannel* newChan,
     338             :                               uint32_t flags,
     339             :                               nsIEventTarget* mainThreadEventTarget = nullptr);
     340             : 
     341             :     // Called by the channel when the response is read from the cache without
     342             :     // communicating with the server.
     343           3 :     void OnExamineCachedResponse(nsIHttpChannel *chan)
     344             :     {
     345           3 :         NotifyObservers(chan, NS_HTTP_ON_EXAMINE_CACHED_RESPONSE_TOPIC);
     346           3 :     }
     347             : 
     348             :     // Generates the host:port string for use in the Host: header as well as the
     349             :     // CONNECT line for proxies. This handles IPv6 literals correctly.
     350             :     static MOZ_MUST_USE nsresult GenerateHostPort(const nsCString& host,
     351             :                                                   int32_t port,
     352             :                                                   nsACString& hostLine);
     353             : 
     354             : 
     355           0 :     SpdyInformation *SpdyInfo() { return &mSpdyInfo; }
     356           0 :     bool IsH2MandatorySuiteEnabled() { return mH2MandatorySuiteEnabled; }
     357             : 
     358             :     // returns true in between Init and Shutdown states
     359          24 :     bool Active() { return mHandlerActive; }
     360             : 
     361           7 :     nsIRequestContextService *GetRequestContextService()
     362             :     {
     363           7 :         return mRequestContextService.get();
     364             :     }
     365             : 
     366             :     void ShutdownConnectionManager();
     367             : 
     368           0 :     bool KeepEmptyResponseHeadersAsEmtpyString() const
     369             :     {
     370           0 :         return mKeepEmptyResponseHeadersAsEmtpyString;
     371             :     }
     372             : 
     373           0 :     uint32_t DefaultHpackBuffer() const
     374             :     {
     375           0 :         return mDefaultHpackBuffer;
     376             :     }
     377             : 
     378           8 :     uint32_t MaxHttpResponseHeaderSize() const
     379             :     {
     380           8 :         return mMaxHttpResponseHeaderSize;
     381             :     }
     382             : 
     383           0 :     float FocusedWindowTransactionRatio() const
     384             :     {
     385           0 :         return mFocusedWindowTransactionRatio;
     386             :     }
     387             : 
     388             : private:
     389             :     virtual ~nsHttpHandler();
     390             : 
     391             :     //
     392             :     // Useragent/prefs helper methods
     393             :     //
     394             :     void     BuildUserAgent();
     395             :     void     InitUserAgentComponents();
     396             :     void     PrefsChanged(nsIPrefBranch *prefs, const char *pref);
     397             : 
     398             :     MOZ_MUST_USE nsresult SetAccept(const char *);
     399             :     MOZ_MUST_USE nsresult SetAcceptLanguages();
     400             :     MOZ_MUST_USE nsresult SetAcceptEncodings(const char *, bool mIsSecure);
     401             : 
     402             :     MOZ_MUST_USE nsresult InitConnectionMgr();
     403             : 
     404             :     void     NotifyObservers(nsIHttpChannel *chan, const char *event);
     405             : 
     406             :     void SetFastOpenOSSupport();
     407             : 
     408             :     void EnsureUAOverridesInit();
     409             : private:
     410             : 
     411             :     // cached services
     412             :     nsMainThreadPtrHandle<nsIIOService>              mIOService;
     413             :     nsMainThreadPtrHandle<nsIStreamConverterService> mStreamConvSvc;
     414             :     nsMainThreadPtrHandle<nsICookieService>          mCookieService;
     415             :     nsMainThreadPtrHandle<nsISiteSecurityService>    mSSService;
     416             : 
     417             :     // the authentication credentials cache
     418             :     nsHttpAuthCache mAuthCache;
     419             :     nsHttpAuthCache mPrivateAuthCache;
     420             : 
     421             :     // the connection manager
     422             :     RefPtr<nsHttpConnectionMgr> mConnMgr;
     423             : 
     424             :     //
     425             :     // prefs
     426             :     //
     427             : 
     428             :     uint8_t  mHttpVersion;
     429             :     uint8_t  mProxyHttpVersion;
     430             :     uint32_t mCapabilities;
     431             :     uint8_t  mReferrerLevel;
     432             :     uint8_t  mSpoofReferrerSource;
     433             :     uint8_t  mHideOnionReferrerSource;
     434             :     uint8_t  mReferrerTrimmingPolicy;
     435             :     uint8_t  mReferrerXOriginTrimmingPolicy;
     436             :     uint8_t  mReferrerXOriginPolicy;
     437             : 
     438             :     bool mFastFallbackToIPv4;
     439             :     PRIntervalTime mIdleTimeout;
     440             :     PRIntervalTime mSpdyTimeout;
     441             :     PRIntervalTime mResponseTimeout;
     442             :     bool mResponseTimeoutEnabled;
     443             :     uint32_t mNetworkChangedTimeout; // milliseconds
     444             :     uint16_t mMaxRequestAttempts;
     445             :     uint16_t mMaxRequestDelay;
     446             :     uint16_t mIdleSynTimeout;
     447             : 
     448             :     bool     mH2MandatorySuiteEnabled;
     449             :     uint16_t mMaxUrgentExcessiveConns;
     450             :     uint16_t mMaxConnections;
     451             :     uint8_t  mMaxPersistentConnectionsPerServer;
     452             :     uint8_t  mMaxPersistentConnectionsPerProxy;
     453             : 
     454             :     bool mThrottleEnabled;
     455             :     uint32_t mThrottleSuspendFor;
     456             :     uint32_t mThrottleResumeFor;
     457             :     uint32_t mThrottleResumeIn;
     458             : 
     459             :     bool mUrgentStartEnabled;
     460             : 
     461             :     uint8_t  mRedirectionLimit;
     462             : 
     463             :     // we'll warn the user if we load an URL containing a userpass field
     464             :     // unless its length is less than this threshold.  this warning is
     465             :     // intended to protect the user against spoofing attempts that use
     466             :     // the userpass field of the URL to obscure the actual origin server.
     467             :     uint8_t  mPhishyUserPassLength;
     468             : 
     469             :     uint8_t  mQoSBits;
     470             : 
     471             :     bool mEnforceAssocReq;
     472             : 
     473             :     nsCString mAccept;
     474             :     nsCString mAcceptLanguages;
     475             :     nsCString mHttpAcceptEncodings;
     476             :     nsCString mHttpsAcceptEncodings;
     477             : 
     478             :     nsXPIDLCString mDefaultSocketType;
     479             : 
     480             :     // cache support
     481             :     uint32_t                  mLastUniqueID;
     482             :     uint32_t                  mSessionStartTime;
     483             : 
     484             :     // useragent components
     485             :     nsCString      mLegacyAppName;
     486             :     nsCString      mLegacyAppVersion;
     487             :     nsCString      mPlatform;
     488             :     nsCString      mOscpu;
     489             :     nsCString      mMisc;
     490             :     nsCString      mProduct;
     491             :     nsXPIDLCString mProductSub;
     492             :     nsXPIDLCString mAppName;
     493             :     nsXPIDLCString mAppVersion;
     494             :     nsCString      mCompatFirefox;
     495             :     bool           mCompatFirefoxEnabled;
     496             :     nsXPIDLCString mCompatDevice;
     497             :     nsCString      mDeviceModelId;
     498             : 
     499             :     nsCString      mUserAgent;
     500             :     nsCString      mSpoofedUserAgent;
     501             :     nsXPIDLCString mUserAgentOverride;
     502             :     bool           mUserAgentIsDirty; // true if mUserAgent should be rebuilt
     503             :     bool           mAcceptLanguagesIsDirty;
     504             : 
     505             : 
     506             :     bool           mPromptTempRedirect;
     507             : 
     508             :     // Persistent HTTPS caching flag
     509             :     bool           mEnablePersistentHttpsCaching;
     510             : 
     511             :     // For broadcasting tracking preference
     512             :     bool           mDoNotTrackEnabled;
     513             : 
     514             :     // for broadcasting safe hint;
     515             :     bool           mSafeHintEnabled;
     516             :     bool           mParentalControlEnabled;
     517             : 
     518             :     // true in between init and shutdown states
     519             :     Atomic<bool, Relaxed> mHandlerActive;
     520             : 
     521             :     // Whether telemetry is reported or not
     522             :     uint32_t           mTelemetryEnabled : 1;
     523             : 
     524             :     // The value of network.allow-experiments
     525             :     uint32_t           mAllowExperiments : 1;
     526             : 
     527             :     // The value of 'hidden' network.http.debug-observations : 1;
     528             :     uint32_t           mDebugObservations : 1;
     529             : 
     530             :     uint32_t           mEnableSpdy : 1;
     531             :     uint32_t           mHttp2Enabled : 1;
     532             :     uint32_t           mUseH2Deps : 1;
     533             :     uint32_t           mEnforceHttp2TlsProfile : 1;
     534             :     uint32_t           mCoalesceSpdy : 1;
     535             :     uint32_t           mSpdyPersistentSettings : 1;
     536             :     uint32_t           mAllowPush : 1;
     537             :     uint32_t           mEnableAltSvc : 1;
     538             :     uint32_t           mEnableAltSvcOE : 1;
     539             :     uint32_t           mEnableOriginExtension : 1;
     540             : 
     541             :     // Try to use SPDY features instead of HTTP/1.1 over SSL
     542             :     SpdyInformation    mSpdyInfo;
     543             : 
     544             :     uint32_t       mSpdySendingChunkSize;
     545             :     uint32_t       mSpdySendBufferSize;
     546             :     uint32_t       mSpdyPushAllowance;
     547             :     uint32_t       mSpdyPullAllowance;
     548             :     uint32_t       mDefaultSpdyConcurrent;
     549             :     PRIntervalTime mSpdyPingThreshold;
     550             :     PRIntervalTime mSpdyPingTimeout;
     551             : 
     552             :     // The maximum amount of time to wait for socket transport to be
     553             :     // established. In milliseconds.
     554             :     uint32_t       mConnectTimeout;
     555             : 
     556             :     // The maximum number of current global half open sockets allowable
     557             :     // when starting a new speculative connection.
     558             :     uint32_t       mParallelSpeculativeConnectLimit;
     559             : 
     560             :     // For Rate Pacing of HTTP/1 requests through a netwerk/base/EventTokenBucket
     561             :     // Active requests <= *MinParallelism are not subject to the rate pacing
     562             :     bool           mRequestTokenBucketEnabled;
     563             :     uint16_t       mRequestTokenBucketMinParallelism;
     564             :     uint32_t       mRequestTokenBucketHz;  // EventTokenBucket HZ
     565             :     uint32_t       mRequestTokenBucketBurst; // EventTokenBucket Burst
     566             : 
     567             :     // Whether or not to block requests for non head js/css items (e.g. media)
     568             :     // while those elements load.
     569             :     bool           mCriticalRequestPrioritization;
     570             : 
     571             :     // TCP Keepalive configuration values.
     572             : 
     573             :     // True if TCP keepalive is enabled for short-lived conns.
     574             :     bool mTCPKeepaliveShortLivedEnabled;
     575             :     // Time (secs) indicating how long a conn is considered short-lived.
     576             :     int32_t mTCPKeepaliveShortLivedTimeS;
     577             :     // Time (secs) before first keepalive probe; between successful probes.
     578             :     int32_t mTCPKeepaliveShortLivedIdleTimeS;
     579             : 
     580             :     // True if TCP keepalive is enabled for long-lived conns.
     581             :     bool mTCPKeepaliveLongLivedEnabled;
     582             :     // Time (secs) before first keepalive probe; between successful probes.
     583             :     int32_t mTCPKeepaliveLongLivedIdleTimeS;
     584             : 
     585             :     // if true, generate NS_ERROR_PARTIAL_TRANSFER for h1 responses with
     586             :     // incorrect content lengths or malformed chunked encodings
     587             :     FrameCheckLevel mEnforceH1Framing;
     588             : 
     589             :     nsCOMPtr<nsIRequestContextService> mRequestContextService;
     590             : 
     591             :     // If it is set to false, headers with empty value will not appear in the
     592             :     // header array - behavior as it used to be. If it is true: empty headers
     593             :     // coming from the network will exits in header array as empty string.
     594             :     // Call SetHeader with an empty value will still delete the header.
     595             :     // (Bug 6699259)
     596             :     bool mKeepEmptyResponseHeadersAsEmtpyString;
     597             : 
     598             :     // The default size (in bytes) of the HPACK decompressor table.
     599             :     uint32_t mDefaultHpackBuffer;
     600             : 
     601             :     // The max size (in bytes) for received Http response header.
     602             :     uint32_t mMaxHttpResponseHeaderSize;
     603             : 
     604             :     // The ratio for dispatching transactions from the focused window.
     605             :     float mFocusedWindowTransactionRatio;
     606             : 
     607             :     Atomic<bool, Relaxed> mUseFastOpen;
     608             :     Atomic<bool, Relaxed> mFastOpenSupported;
     609             :     uint32_t mFastOpenConsecutiveFailureLimit;
     610             :     uint32_t mFastOpenConsecutiveFailureCounter;
     611             : 
     612             : private:
     613             :     // For Rate Pacing Certain Network Events. Only assign this pointer on
     614             :     // socket thread.
     615             :     void MakeNewRequestTokenBucket();
     616             :     RefPtr<EventTokenBucket> mRequestTokenBucket;
     617             : 
     618             : public:
     619             :     // Socket thread only
     620           3 :     MOZ_MUST_USE nsresult SubmitPacedRequest(ATokenBucketEvent *event,
     621             :                                              nsICancelable **cancel)
     622             :     {
     623           3 :         MOZ_ASSERT(OnSocketThread(), "not on socket thread");
     624           3 :         if (!mRequestTokenBucket) {
     625           0 :             return NS_ERROR_NOT_AVAILABLE;
     626             :         }
     627           3 :         return mRequestTokenBucket->SubmitEvent(event, cancel);
     628             :     }
     629             : 
     630             :     // Socket thread only
     631           1 :     void SetRequestTokenBucket(EventTokenBucket *aTokenBucket)
     632             :     {
     633           1 :         MOZ_ASSERT(OnSocketThread(), "not on socket thread");
     634           1 :         mRequestTokenBucket = aTokenBucket;
     635           1 :     }
     636             : 
     637           0 :     void StopRequestTokenBucket()
     638             :     {
     639           0 :         MOZ_ASSERT(OnSocketThread(), "not on socket thread");
     640           0 :         if (mRequestTokenBucket) {
     641           0 :             mRequestTokenBucket->Stop();
     642           0 :             mRequestTokenBucket = nullptr;
     643             :         }
     644           0 :     }
     645             : 
     646             : private:
     647             :     RefPtr<Tickler> mWifiTickler;
     648             :     void TickleWifi(nsIInterfaceRequestor *cb);
     649             : 
     650             : private:
     651             :     MOZ_MUST_USE nsresult
     652             :     SpeculativeConnectInternal(nsIURI *aURI,
     653             :                                nsIPrincipal *aPrincipal,
     654             :                                nsIInterfaceRequestor *aCallbacks,
     655             :                                bool anonymous);
     656             : 
     657             :     // State for generating channelIds
     658             :     uint32_t mProcessId;
     659             :     uint32_t mNextChannelId;
     660             : 
     661             : public:
     662             :     MOZ_MUST_USE nsresult NewChannelId(uint64_t& channelId);
     663             : };
     664             : 
     665             : extern nsHttpHandler *gHttpHandler;
     666             : 
     667             : //-----------------------------------------------------------------------------
     668             : // nsHttpsHandler - thin wrapper to distinguish the HTTP handler from the
     669             : //                  HTTPS handler (even though they share the same impl).
     670             : //-----------------------------------------------------------------------------
     671             : 
     672             : class nsHttpsHandler : public nsIHttpProtocolHandler
     673             :                      , public nsSupportsWeakReference
     674             :                      , public nsISpeculativeConnect
     675             : {
     676           0 :     virtual ~nsHttpsHandler() { }
     677             : public:
     678             :     // we basically just want to override GetScheme and GetDefaultPort...
     679             :     // all other methods should be forwarded to the nsHttpHandler instance.
     680             : 
     681             :     NS_DECL_THREADSAFE_ISUPPORTS
     682             :     NS_DECL_NSIPROTOCOLHANDLER
     683           0 :     NS_FORWARD_NSIPROXIEDPROTOCOLHANDLER (gHttpHandler->)
     684           0 :     NS_FORWARD_NSIHTTPPROTOCOLHANDLER    (gHttpHandler->)
     685           0 :     NS_FORWARD_NSISPECULATIVECONNECT     (gHttpHandler->)
     686             : 
     687           1 :     nsHttpsHandler() { }
     688             : 
     689             :     MOZ_MUST_USE nsresult Init();
     690             : };
     691             : 
     692             : } // namespace net
     693             : } // namespace mozilla
     694             : 
     695             : #endif // nsHttpHandler_h__

Generated by: LCOV version 1.13