2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsHttpHandler_h__
|
|
|
|
#define nsHttpHandler_h__
|
|
|
|
|
|
|
|
#include "nsHttp.h"
|
|
|
|
#include "nsHttpAuthCache.h"
|
|
|
|
#include "nsHttpConnectionMgr.h"
|
2012-05-25 14:37:01 -07:00
|
|
|
#include "ASpdySession.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsWeakReference.h"
|
|
|
|
|
|
|
|
#include "nsIHttpProtocolHandler.h"
|
|
|
|
#include "nsIObserver.h"
|
2012-04-25 05:54:42 -07:00
|
|
|
#include "nsISpeculativeConnect.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsIHttpChannel;
|
|
|
|
class nsIPrefBranch;
|
2013-04-15 05:50:35 -07:00
|
|
|
class nsICancelable;
|
2013-09-22 20:35:52 -07:00
|
|
|
class nsICookieService;
|
|
|
|
class nsIIOService;
|
|
|
|
class nsIObserverService;
|
|
|
|
class nsISiteSecurityService;
|
|
|
|
class nsIStreamConverterService;
|
|
|
|
class nsITimer;
|
2013-04-15 05:50:35 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
class ATokenBucketEvent;
|
|
|
|
class EventTokenBucket;
|
2013-07-11 08:39:36 -07:00
|
|
|
class Tickler;
|
2014-01-07 14:05:56 -08:00
|
|
|
class nsHttpConnection;
|
|
|
|
class nsHttpConnectionInfo;
|
|
|
|
class nsHttpTransaction;
|
2014-08-21 07:50:17 -07:00
|
|
|
class AltSvcMapping;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2015-02-24 16:16:00 -08:00
|
|
|
enum FrameCheckLevel {
|
|
|
|
FRAMECHECK_LAX,
|
|
|
|
FRAMECHECK_BARELY,
|
|
|
|
FRAMECHECK_STRICT
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// nsHttpHandler - protocol handler for HTTP and HTTPS
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
class nsHttpHandler final : public nsIHttpProtocolHandler
|
2015-03-27 11:52:19 -07:00
|
|
|
, public nsIObserver
|
|
|
|
, public nsSupportsWeakReference
|
|
|
|
, public nsISpeculativeConnect
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2013-07-18 19:24:13 -07:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_NSIPROTOCOLHANDLER
|
|
|
|
NS_DECL_NSIPROXIEDPROTOCOLHANDLER
|
|
|
|
NS_DECL_NSIHTTPPROTOCOLHANDLER
|
|
|
|
NS_DECL_NSIOBSERVER
|
2012-04-25 05:54:42 -07:00
|
|
|
NS_DECL_NSISPECULATIVECONNECT
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsHttpHandler();
|
|
|
|
|
|
|
|
nsresult Init();
|
2012-09-14 13:27:46 -07:00
|
|
|
nsresult AddStandardRequestHeaders(nsHttpHeaderArray *);
|
|
|
|
nsresult AddConnectionHeader(nsHttpHeaderArray *,
|
2012-11-29 17:34:35 -08:00
|
|
|
uint32_t capabilities);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsAcceptableEncoding(const char *encoding);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
const nsAFlatCString &UserAgent();
|
|
|
|
|
|
|
|
nsHttpVersion HttpVersion() { return mHttpVersion; }
|
|
|
|
nsHttpVersion ProxyHttpVersion() { return mProxyHttpVersion; }
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t ReferrerLevel() { return mReferrerLevel; }
|
2013-11-15 18:46:37 -08:00
|
|
|
bool SpoofReferrerSource() { return mSpoofReferrerSource; }
|
|
|
|
uint8_t ReferrerTrimmingPolicy() { return mReferrerTrimmingPolicy; }
|
|
|
|
uint8_t ReferrerXOriginPolicy() { return mReferrerXOriginPolicy; }
|
2011-09-28 23:19:26 -07:00
|
|
|
bool SendSecureXSiteReferrer() { return mSendSecureXSiteReferrer; }
|
2015-06-02 15:46:02 -07:00
|
|
|
bool PackagedAppsEnabled() { return mPackagedAppsEnabled; }
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t RedirectionLimit() { return mRedirectionLimit; }
|
2012-02-23 17:58:43 -08:00
|
|
|
PRIntervalTime IdleTimeout() { return mIdleTimeout; }
|
|
|
|
PRIntervalTime SpdyTimeout() { return mSpdyTimeout; }
|
2014-06-26 11:03:45 -07:00
|
|
|
PRIntervalTime ResponseTimeout() {
|
|
|
|
return mResponseTimeoutEnabled ? mResponseTimeout : 0;
|
|
|
|
}
|
|
|
|
PRIntervalTime ResponseTimeoutEnabled() { return mResponseTimeoutEnabled; }
|
2014-09-11 03:55:00 -07:00
|
|
|
uint32_t NetworkChangedTimeout() { return mNetworkChangedTimeout; }
|
2012-08-22 08:56:38 -07:00
|
|
|
uint16_t MaxRequestAttempts() { return mMaxRequestAttempts; }
|
2007-03-22 10:30:00 -07:00
|
|
|
const char *DefaultSocketType() { return mDefaultSocketType.get(); /* ok to return null */ }
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t PhishyUserPassLength() { return mPhishyUserPassLength; }
|
|
|
|
uint8_t GetQoSBits() { return mQoSBits; }
|
|
|
|
uint16_t GetIdleSynTimeout() { return mIdleSynTimeout; }
|
2011-09-28 23:19:26 -07:00
|
|
|
bool FastFallbackToIPv4() { return mFastFallbackToIPv4; }
|
2012-09-14 13:27:46 -07:00
|
|
|
bool ProxyPipelining() { return mProxyPipelining; }
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t MaxSocketCount();
|
2012-03-22 16:39:31 -07:00
|
|
|
bool EnforceAssocReq() { return mEnforceAssocReq; }
|
2011-08-27 03:49:40 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsPersistentHttpsCachingEnabled() { return mEnablePersistentHttpsCaching; }
|
2012-02-27 07:32:09 -08:00
|
|
|
bool IsTelemetryEnabled() { return mTelemetryEnabled; }
|
|
|
|
bool AllowExperiments() { return mTelemetryEnabled && mAllowExperiments; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-12-13 07:55:50 -08:00
|
|
|
bool IsSpdyEnabled() { return mEnableSpdy; }
|
2013-07-26 14:22:46 -07:00
|
|
|
bool IsSpdyV31Enabled() { return mSpdyV31; }
|
2015-05-12 10:45:15 -07:00
|
|
|
bool IsHttp2Enabled() { return mHttp2Enabled; }
|
2013-10-09 17:21:49 -07:00
|
|
|
bool EnforceHttp2TlsProfile() { return mEnforceHttp2TlsProfile; }
|
2011-12-13 07:55:50 -08:00
|
|
|
bool CoalesceSpdy() { return mCoalesceSpdy; }
|
2013-01-30 17:34:25 -08:00
|
|
|
bool UseSpdyPersistentSettings() { return mSpdyPersistentSettings; }
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t SpdySendingChunkSize() { return mSpdySendingChunkSize; }
|
2012-10-06 17:48:20 -07:00
|
|
|
uint32_t SpdySendBufferSize() { return mSpdySendBufferSize; }
|
2013-05-28 21:07:03 -07:00
|
|
|
uint32_t SpdyPushAllowance() { return mSpdyPushAllowance; }
|
2015-01-26 13:06:44 -08:00
|
|
|
uint32_t DefaultSpdyConcurrent() { return mDefaultSpdyConcurrent; }
|
2012-02-23 17:58:43 -08:00
|
|
|
PRIntervalTime SpdyPingThreshold() { return mSpdyPingThreshold; }
|
|
|
|
PRIntervalTime SpdyPingTimeout() { return mSpdyPingTimeout; }
|
2013-10-09 17:21:49 -07:00
|
|
|
bool AllowPush() { return mAllowPush; }
|
2014-08-21 07:50:17 -07:00
|
|
|
bool AllowAltSvc() { return mEnableAltSvc; }
|
|
|
|
bool AllowAltSvcOE() { return mEnableAltSvcOE; }
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t ConnectTimeout() { return mConnectTimeout; }
|
2012-12-04 15:06:29 -08:00
|
|
|
uint32_t ParallelSpeculativeConnectLimit() { return mParallelSpeculativeConnectLimit; }
|
2013-11-13 05:31:20 -08:00
|
|
|
bool CriticalRequestPrioritization() { return mCriticalRequestPrioritization; }
|
2014-12-06 11:26:50 -08:00
|
|
|
bool UseH2Deps() { return mUseH2Deps; }
|
2011-12-13 07:55:50 -08:00
|
|
|
|
2014-04-16 06:52:43 -07:00
|
|
|
uint32_t MaxConnectionsPerOrigin() { return mMaxPersistentConnectionsPerServer; }
|
2013-04-15 05:50:35 -07:00
|
|
|
bool UseRequestTokenBucket() { return mRequestTokenBucketEnabled; }
|
2013-05-08 08:43:31 -07:00
|
|
|
uint16_t RequestTokenBucketMinParallelism() { return mRequestTokenBucketMinParallelism; }
|
|
|
|
uint32_t RequestTokenBucketHz() { return mRequestTokenBucketHz; }
|
|
|
|
uint32_t RequestTokenBucketBurst() {return mRequestTokenBucketBurst; }
|
2013-04-15 05:50:35 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool PromptTempRedirect() { return mPromptTempRedirect; }
|
2009-02-24 11:46:51 -08:00
|
|
|
|
2014-02-06 11:51:38 -08:00
|
|
|
// TCP Keepalive configuration values.
|
|
|
|
|
|
|
|
// Returns true if TCP keepalive should be enabled for short-lived conns.
|
|
|
|
bool TCPKeepaliveEnabledForShortLivedConns() {
|
|
|
|
return mTCPKeepaliveShortLivedEnabled;
|
|
|
|
}
|
|
|
|
// Return time (secs) that a connection is consider short lived (for TCP
|
|
|
|
// keepalive purposes). After this time, the connection is long-lived.
|
|
|
|
int32_t GetTCPKeepaliveShortLivedTime() {
|
|
|
|
return mTCPKeepaliveShortLivedTimeS;
|
|
|
|
}
|
|
|
|
// Returns time (secs) before first TCP keepalive probes should be sent;
|
|
|
|
// same time used between successful keepalive probes.
|
|
|
|
int32_t GetTCPKeepaliveShortLivedIdleTime() {
|
|
|
|
return mTCPKeepaliveShortLivedIdleTimeS;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns true if TCP keepalive should be enabled for long-lived conns.
|
|
|
|
bool TCPKeepaliveEnabledForLongLivedConns() {
|
|
|
|
return mTCPKeepaliveLongLivedEnabled;
|
|
|
|
}
|
|
|
|
// Returns time (secs) before first TCP keepalive probes should be sent;
|
|
|
|
// same time used between successful keepalive probes.
|
|
|
|
int32_t GetTCPKeepaliveLongLivedIdleTime() {
|
|
|
|
return mTCPKeepaliveLongLivedIdleTimeS;
|
|
|
|
}
|
|
|
|
|
2015-02-24 16:16:00 -08:00
|
|
|
// returns the HTTP framing check level preference, as controlled with
|
|
|
|
// network.http.enforce-framing.http1 and network.http.enforce-framing.soft
|
|
|
|
FrameCheckLevel GetEnforceH1Framing() { return mEnforceH1Framing; }
|
2014-10-24 13:19:40 -07:00
|
|
|
|
2012-10-29 13:20:03 -07:00
|
|
|
nsHttpAuthCache *AuthCache(bool aPrivate) {
|
|
|
|
return aPrivate ? &mPrivateAuthCache : &mAuthCache;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
nsHttpConnectionMgr *ConnMgr() { return mConnMgr; }
|
|
|
|
|
|
|
|
// cache support
|
2012-05-31 15:20:05 -07:00
|
|
|
bool UseCache() const { return mUseCache; }
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t GenerateUniqueID() { return ++mLastUniqueID; }
|
|
|
|
uint32_t SessionStartTime() { return mSessionStartTime; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
//
|
|
|
|
// Connection management methods:
|
|
|
|
//
|
|
|
|
// - the handler only owns idle connections; it does not own active
|
|
|
|
// connections.
|
|
|
|
//
|
|
|
|
// - the handler keeps a count of active connections to enforce the
|
|
|
|
// steady-state max-connections pref.
|
2013-05-16 06:30:42 -07:00
|
|
|
//
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Called to kick-off a new transaction, by default the transaction
|
2013-05-16 06:30:42 -07:00
|
|
|
// will be put on the pending transaction queue if it cannot be
|
2007-03-22 10:30:00 -07:00
|
|
|
// initiated at this time. Callable from any thread.
|
2012-08-22 08:56:38 -07:00
|
|
|
nsresult InitiateTransaction(nsHttpTransaction *trans, int32_t priority)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return mConnMgr->AddTransaction(trans, priority);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Called to change the priority of an existing transaction that has
|
|
|
|
// already been initiated.
|
2012-08-22 08:56:38 -07:00
|
|
|
nsresult RescheduleTransaction(nsHttpTransaction *trans, int32_t priority)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return mConnMgr->RescheduleTransaction(trans, priority);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Called to cancel a transaction, which may or may not be assigned to
|
|
|
|
// a connection. Callable from any thread.
|
|
|
|
nsresult CancelTransaction(nsHttpTransaction *trans, nsresult reason)
|
|
|
|
{
|
|
|
|
return mConnMgr->CancelTransaction(trans, reason);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Called when a connection is done processing a transaction. Callable
|
|
|
|
// from any thread.
|
|
|
|
nsresult ReclaimConnection(nsHttpConnection *conn)
|
|
|
|
{
|
|
|
|
return mConnMgr->ReclaimConnection(conn);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult ProcessPendingQ(nsHttpConnectionInfo *cinfo)
|
|
|
|
{
|
|
|
|
return mConnMgr->ProcessPendingQ(cinfo);
|
|
|
|
}
|
|
|
|
|
2012-12-04 15:06:29 -08:00
|
|
|
nsresult ProcessPendingQ()
|
|
|
|
{
|
|
|
|
return mConnMgr->ProcessPendingQ();
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult GetSocketThreadTarget(nsIEventTarget **target)
|
|
|
|
{
|
|
|
|
return mConnMgr->GetSocketThreadTarget(target);
|
|
|
|
}
|
|
|
|
|
2012-04-25 05:54:42 -07:00
|
|
|
nsresult SpeculativeConnect(nsHttpConnectionInfo *ci,
|
2013-06-28 13:58:28 -07:00
|
|
|
nsIInterfaceRequestor *callbacks,
|
|
|
|
uint32_t caps = 0)
|
2012-04-25 05:54:42 -07:00
|
|
|
{
|
2013-07-11 08:39:36 -07:00
|
|
|
TickleWifi(callbacks);
|
2013-06-28 13:58:28 -07:00
|
|
|
return mConnMgr->SpeculativeConnect(ci, callbacks, caps);
|
2012-04-25 05:54:42 -07:00
|
|
|
}
|
|
|
|
|
2014-08-21 07:50:17 -07:00
|
|
|
// Alternate Services Maps are main thread only
|
|
|
|
void UpdateAltServiceMapping(AltSvcMapping *map,
|
|
|
|
nsProxyInfo *proxyInfo,
|
|
|
|
nsIInterfaceRequestor *callbacks,
|
|
|
|
uint32_t caps)
|
|
|
|
{
|
|
|
|
mConnMgr->UpdateAltServiceMapping(map, proxyInfo, callbacks, caps);
|
|
|
|
}
|
|
|
|
|
|
|
|
AltSvcMapping *GetAltServiceMapping(const nsACString &scheme,
|
|
|
|
const nsACString &host,
|
|
|
|
int32_t port, bool pb)
|
|
|
|
{
|
|
|
|
return mConnMgr->GetAltServiceMapping(scheme, host, port, pb);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//
|
|
|
|
// The HTTP handler caches pointers to specific XPCOM services, and
|
|
|
|
// provides the following helper routines for accessing those services:
|
|
|
|
//
|
|
|
|
nsresult GetStreamConverterService(nsIStreamConverterService **);
|
|
|
|
nsresult GetIOService(nsIIOService** service);
|
|
|
|
nsICookieService * GetCookieService(); // not addrefed
|
2013-08-02 15:48:37 -07:00
|
|
|
nsISiteSecurityService * GetSSService();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-07-24 07:05:36 -07:00
|
|
|
// callable from socket thread only
|
|
|
|
uint32_t Get32BitsOfPseudoRandom();
|
|
|
|
|
2012-11-27 11:54:58 -08:00
|
|
|
// Called by the channel synchronously during asyncOpen
|
|
|
|
void OnOpeningRequest(nsIHttpChannel *chan)
|
|
|
|
{
|
|
|
|
NotifyObservers(chan, NS_HTTP_ON_OPENING_REQUEST_TOPIC);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Called by the channel before writing a request
|
|
|
|
void OnModifyRequest(nsIHttpChannel *chan)
|
|
|
|
{
|
|
|
|
NotifyObservers(chan, NS_HTTP_ON_MODIFY_REQUEST_TOPIC);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Called by the channel once headers are available
|
|
|
|
void OnExamineResponse(nsIHttpChannel *chan)
|
|
|
|
{
|
|
|
|
NotifyObservers(chan, NS_HTTP_ON_EXAMINE_RESPONSE_TOPIC);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Called by the channel once headers have been merged with cached headers
|
|
|
|
void OnExamineMergedResponse(nsIHttpChannel *chan)
|
|
|
|
{
|
|
|
|
NotifyObservers(chan, NS_HTTP_ON_EXAMINE_MERGED_RESPONSE_TOPIC);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Called by channels before a redirect happens. This notifies both the
|
|
|
|
// channel's and the global redirect observers.
|
2010-07-28 11:33:06 -07:00
|
|
|
nsresult AsyncOnChannelRedirect(nsIChannel* oldChan, nsIChannel* newChan,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t flags);
|
2009-02-11 20:16:00 -08:00
|
|
|
|
|
|
|
// Called by the channel when the response is read from the cache without
|
|
|
|
// communicating with the server.
|
|
|
|
void OnExamineCachedResponse(nsIHttpChannel *chan)
|
|
|
|
{
|
|
|
|
NotifyObservers(chan, NS_HTTP_ON_EXAMINE_CACHED_RESPONSE_TOPIC);
|
|
|
|
}
|
2010-02-18 06:42:32 -08:00
|
|
|
|
|
|
|
// Generates the host:port string for use in the Host: header as well as the
|
|
|
|
// CONNECT line for proxies. This handles IPv6 literals correctly.
|
2012-08-22 08:56:38 -07:00
|
|
|
static nsresult GenerateHostPort(const nsCString& host, int32_t port,
|
2014-04-22 12:46:06 -07:00
|
|
|
nsACString& hostLine);
|
2010-02-18 06:42:32 -08:00
|
|
|
|
2012-03-22 16:39:31 -07:00
|
|
|
bool GetPipelineAggressive() { return mPipelineAggressive; }
|
2012-08-22 08:56:38 -07:00
|
|
|
void GetMaxPipelineObjectSize(int64_t *outVal)
|
2012-03-22 16:39:31 -07:00
|
|
|
{
|
2012-04-09 07:21:17 -07:00
|
|
|
*outVal = mMaxPipelineObjectSize;
|
2012-03-22 16:39:31 -07:00
|
|
|
}
|
2012-04-11 10:49:32 -07:00
|
|
|
|
|
|
|
bool GetPipelineEnabled()
|
|
|
|
{
|
|
|
|
return mCapabilities & NS_HTTP_ALLOW_PIPELINING;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetPipelineRescheduleOnTimeout()
|
|
|
|
{
|
|
|
|
return mPipelineRescheduleOnTimeout;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRIntervalTime GetPipelineRescheduleTimeout()
|
|
|
|
{
|
|
|
|
return mPipelineRescheduleTimeout;
|
|
|
|
}
|
2013-05-16 06:30:42 -07:00
|
|
|
|
2012-03-22 16:39:31 -07:00
|
|
|
PRIntervalTime GetPipelineTimeout() { return mPipelineReadTimeout; }
|
2012-03-22 16:39:31 -07:00
|
|
|
|
2014-01-07 14:05:56 -08:00
|
|
|
SpdyInformation *SpdyInfo() { return &mSpdyInfo; }
|
2015-01-15 19:11:14 -08:00
|
|
|
bool IsH2MandatorySuiteEnabled() { return mH2MandatorySuiteEnabled; }
|
2012-05-25 14:37:01 -07:00
|
|
|
|
2012-09-14 13:27:46 -07:00
|
|
|
// returns true in between Init and Shutdown states
|
|
|
|
bool Active() { return mHandlerActive; }
|
|
|
|
|
2013-05-12 07:01:13 -07:00
|
|
|
// When the disk cache is responding slowly its use is suppressed
|
|
|
|
// for 1 minute for most requests. Callable from main thread only.
|
2014-01-07 14:05:56 -08:00
|
|
|
TimeStamp GetCacheSkippedUntil() { return mCacheSkippedUntil; }
|
|
|
|
void SetCacheSkippedUntil(TimeStamp arg) { mCacheSkippedUntil = arg; }
|
|
|
|
void ClearCacheSkippedUntil() { mCacheSkippedUntil = TimeStamp(); }
|
2013-05-12 07:01:13 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
2014-06-24 09:36:44 -07:00
|
|
|
virtual ~nsHttpHandler();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
//
|
|
|
|
// Useragent/prefs helper methods
|
|
|
|
//
|
|
|
|
void BuildUserAgent();
|
|
|
|
void InitUserAgentComponents();
|
|
|
|
void PrefsChanged(nsIPrefBranch *prefs, const char *pref);
|
|
|
|
|
|
|
|
nsresult SetAccept(const char *);
|
|
|
|
nsresult SetAcceptLanguages(const char *);
|
|
|
|
nsresult SetAcceptEncodings(const char *);
|
|
|
|
|
|
|
|
nsresult InitConnectionMgr();
|
|
|
|
|
|
|
|
void NotifyObservers(nsIHttpChannel *chan, const char *event);
|
|
|
|
|
2012-10-04 18:08:58 -07:00
|
|
|
static void TimerCallback(nsITimer * aTimer, void * aClosure);
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
|
|
|
|
|
|
|
// cached services
|
2013-08-13 12:36:59 -07:00
|
|
|
nsMainThreadPtrHandle<nsIIOService> mIOService;
|
|
|
|
nsMainThreadPtrHandle<nsIStreamConverterService> mStreamConvSvc;
|
|
|
|
nsMainThreadPtrHandle<nsIObserverService> mObserverService;
|
|
|
|
nsMainThreadPtrHandle<nsICookieService> mCookieService;
|
|
|
|
nsMainThreadPtrHandle<nsISiteSecurityService> mSSService;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// the authentication credentials cache
|
|
|
|
nsHttpAuthCache mAuthCache;
|
2012-10-29 13:20:03 -07:00
|
|
|
nsHttpAuthCache mPrivateAuthCache;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// the connection manager
|
2014-02-17 10:53:25 -08:00
|
|
|
nsHttpConnectionMgr *mConnMgr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
//
|
|
|
|
// prefs
|
|
|
|
//
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t mHttpVersion;
|
|
|
|
uint8_t mProxyHttpVersion;
|
2012-11-29 17:34:35 -08:00
|
|
|
uint32_t mCapabilities;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t mReferrerLevel;
|
2013-11-15 18:46:37 -08:00
|
|
|
uint8_t mSpoofReferrerSource;
|
|
|
|
uint8_t mReferrerTrimmingPolicy;
|
|
|
|
uint8_t mReferrerXOriginPolicy;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mFastFallbackToIPv4;
|
2012-09-14 13:27:46 -07:00
|
|
|
bool mProxyPipelining;
|
2012-02-23 17:58:43 -08:00
|
|
|
PRIntervalTime mIdleTimeout;
|
|
|
|
PRIntervalTime mSpdyTimeout;
|
2013-12-18 15:03:48 -08:00
|
|
|
PRIntervalTime mResponseTimeout;
|
2014-06-26 11:03:45 -07:00
|
|
|
bool mResponseTimeoutEnabled;
|
2014-09-11 03:55:00 -07:00
|
|
|
uint32_t mNetworkChangedTimeout; // milliseconds
|
2012-08-22 08:56:38 -07:00
|
|
|
uint16_t mMaxRequestAttempts;
|
|
|
|
uint16_t mMaxRequestDelay;
|
|
|
|
uint16_t mIdleSynTimeout;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2015-01-15 19:11:14 -08:00
|
|
|
bool mH2MandatorySuiteEnabled;
|
2012-10-04 18:08:58 -07:00
|
|
|
bool mPipeliningEnabled;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint16_t mMaxConnections;
|
|
|
|
uint8_t mMaxPersistentConnectionsPerServer;
|
|
|
|
uint8_t mMaxPersistentConnectionsPerProxy;
|
|
|
|
uint16_t mMaxPipelinedRequests;
|
|
|
|
uint16_t mMaxOptimisticPipelinedRequests;
|
2012-03-22 16:39:31 -07:00
|
|
|
bool mPipelineAggressive;
|
2012-08-22 08:56:38 -07:00
|
|
|
int64_t mMaxPipelineObjectSize;
|
2012-04-11 10:49:32 -07:00
|
|
|
bool mPipelineRescheduleOnTimeout;
|
|
|
|
PRIntervalTime mPipelineRescheduleTimeout;
|
2012-03-22 16:39:31 -07:00
|
|
|
PRIntervalTime mPipelineReadTimeout;
|
2012-10-04 18:08:58 -07:00
|
|
|
nsCOMPtr<nsITimer> mPipelineTestTimer;
|
2012-03-22 16:39:31 -07:00
|
|
|
|
2015-06-02 15:46:02 -07:00
|
|
|
// Whether a URL containing !// should be interpreted as a packaged app channel
|
|
|
|
bool mPackagedAppsEnabled = false;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t mRedirectionLimit;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// we'll warn the user if we load an URL containing a userpass field
|
|
|
|
// unless its length is less than this threshold. this warning is
|
|
|
|
// intended to protect the user against spoofing attempts that use
|
|
|
|
// the userpass field of the URL to obscure the actual origin server.
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t mPhishyUserPassLength;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t mQoSBits;
|
2010-06-02 19:25:01 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mPipeliningOverSSL;
|
2012-03-22 16:39:31 -07:00
|
|
|
bool mEnforceAssocReq;
|
2008-02-06 20:04:56 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCString mAccept;
|
|
|
|
nsCString mAcceptLanguages;
|
|
|
|
nsCString mAcceptEncodings;
|
|
|
|
|
|
|
|
nsXPIDLCString mDefaultSocketType;
|
|
|
|
|
|
|
|
// cache support
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mLastUniqueID;
|
|
|
|
uint32_t mSessionStartTime;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// useragent components
|
2010-08-27 00:02:10 -07:00
|
|
|
nsCString mLegacyAppName;
|
|
|
|
nsCString mLegacyAppVersion;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCString mPlatform;
|
|
|
|
nsCString mOscpu;
|
|
|
|
nsCString mMisc;
|
2007-07-02 11:20:24 -07:00
|
|
|
nsCString mProduct;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsXPIDLCString mProductSub;
|
2010-08-27 00:02:10 -07:00
|
|
|
nsXPIDLCString mAppName;
|
|
|
|
nsXPIDLCString mAppVersion;
|
|
|
|
nsCString mCompatFirefox;
|
2012-06-22 04:52:47 -07:00
|
|
|
bool mCompatFirefoxEnabled;
|
2012-01-31 20:04:23 -08:00
|
|
|
nsXPIDLCString mCompatDevice;
|
2014-10-01 20:44:29 -07:00
|
|
|
nsCString mDeviceModelId;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsCString mUserAgent;
|
|
|
|
nsXPIDLCString mUserAgentOverride;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mUserAgentIsDirty; // true if mUserAgent should be rebuilt
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mUseCache;
|
2009-02-24 11:46:51 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mPromptTempRedirect;
|
2013-05-16 06:30:42 -07:00
|
|
|
// mSendSecureXSiteReferrer: default is false,
|
2007-03-22 10:30:00 -07:00
|
|
|
// if true allow referrer headers between secure non-matching hosts
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mSendSecureXSiteReferrer;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Persistent HTTPS caching flag
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mEnablePersistentHttpsCaching;
|
2011-01-05 11:53:21 -08:00
|
|
|
|
2012-06-14 14:19:27 -07:00
|
|
|
// For broadcasting tracking preference
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mDoNotTrackEnabled;
|
2012-06-14 14:19:27 -07:00
|
|
|
|
2014-04-13 21:39:13 -07:00
|
|
|
// for broadcasting safe hint;
|
|
|
|
bool mSafeHintEnabled;
|
2014-05-05 14:30:42 -07:00
|
|
|
bool mParentalControlEnabled;
|
2014-04-13 21:39:13 -07:00
|
|
|
|
2012-02-27 07:32:09 -08:00
|
|
|
// Whether telemetry is reported or not
|
2013-10-09 17:21:49 -07:00
|
|
|
uint32_t mTelemetryEnabled : 1;
|
2012-02-27 07:32:09 -08:00
|
|
|
|
|
|
|
// The value of network.allow-experiments
|
2013-10-09 17:21:49 -07:00
|
|
|
uint32_t mAllowExperiments : 1;
|
2012-02-27 07:32:09 -08:00
|
|
|
|
2015-06-24 10:50:37 -07:00
|
|
|
// The value of 'hidden' network.http.debug-observations : 1;
|
|
|
|
uint32_t mDebugObservations : 1;
|
|
|
|
|
2012-09-14 13:27:46 -07:00
|
|
|
// true in between init and shutdown states
|
2013-10-09 17:21:49 -07:00
|
|
|
uint32_t mHandlerActive : 1;
|
|
|
|
|
|
|
|
uint32_t mEnableSpdy : 1;
|
|
|
|
uint32_t mSpdyV31 : 1;
|
2014-09-23 10:49:13 -07:00
|
|
|
uint32_t mHttp2Enabled : 1;
|
2014-12-06 11:26:50 -08:00
|
|
|
uint32_t mUseH2Deps : 1;
|
2013-10-09 17:21:49 -07:00
|
|
|
uint32_t mEnforceHttp2TlsProfile : 1;
|
|
|
|
uint32_t mCoalesceSpdy : 1;
|
|
|
|
uint32_t mSpdyPersistentSettings : 1;
|
|
|
|
uint32_t mAllowPush : 1;
|
2014-08-21 07:50:17 -07:00
|
|
|
uint32_t mEnableAltSvc : 1;
|
|
|
|
uint32_t mEnableAltSvcOE : 1;
|
2012-09-14 13:27:46 -07:00
|
|
|
|
2011-12-13 07:55:50 -08:00
|
|
|
// Try to use SPDY features instead of HTTP/1.1 over SSL
|
2013-10-09 17:21:49 -07:00
|
|
|
SpdyInformation mSpdyInfo;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mSpdySendingChunkSize;
|
2012-10-06 17:48:20 -07:00
|
|
|
uint32_t mSpdySendBufferSize;
|
2013-05-28 21:07:03 -07:00
|
|
|
uint32_t mSpdyPushAllowance;
|
2015-01-26 13:06:44 -08:00
|
|
|
uint32_t mDefaultSpdyConcurrent;
|
2012-02-23 17:58:43 -08:00
|
|
|
PRIntervalTime mSpdyPingThreshold;
|
|
|
|
PRIntervalTime mSpdyPingTimeout;
|
2012-07-23 16:10:00 -07:00
|
|
|
|
|
|
|
// The maximum amount of time to wait for socket transport to be
|
|
|
|
// established. In milliseconds.
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mConnectTimeout;
|
2012-12-04 15:06:29 -08:00
|
|
|
|
|
|
|
// The maximum number of current global half open sockets allowable
|
|
|
|
// when starting a new speculative connection.
|
|
|
|
uint32_t mParallelSpeculativeConnectLimit;
|
2012-12-04 15:06:29 -08:00
|
|
|
|
2015-01-20 00:58:00 -08:00
|
|
|
// For Rate Pacing of HTTP/1 requests through a netwerk/base/EventTokenBucket
|
2013-04-15 05:50:35 -07:00
|
|
|
// Active requests <= *MinParallelism are not subject to the rate pacing
|
|
|
|
bool mRequestTokenBucketEnabled;
|
|
|
|
uint16_t mRequestTokenBucketMinParallelism;
|
|
|
|
uint32_t mRequestTokenBucketHz; // EventTokenBucket HZ
|
|
|
|
uint32_t mRequestTokenBucketBurst; // EventTokenBucket Burst
|
|
|
|
|
2012-12-04 15:06:29 -08:00
|
|
|
// Whether or not to block requests for non head js/css items (e.g. media)
|
|
|
|
// while those elements load.
|
2013-11-13 05:31:20 -08:00
|
|
|
bool mCriticalRequestPrioritization;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-12 07:01:13 -07:00
|
|
|
// When the disk cache is responding slowly its use is suppressed
|
|
|
|
// for 1 minute for most requests.
|
2014-01-07 14:05:56 -08:00
|
|
|
TimeStamp mCacheSkippedUntil;
|
2013-05-12 07:01:13 -07:00
|
|
|
|
2014-02-06 11:51:38 -08:00
|
|
|
// TCP Keepalive configuration values.
|
|
|
|
|
|
|
|
// True if TCP keepalive is enabled for short-lived conns.
|
|
|
|
bool mTCPKeepaliveShortLivedEnabled;
|
|
|
|
// Time (secs) indicating how long a conn is considered short-lived.
|
|
|
|
int32_t mTCPKeepaliveShortLivedTimeS;
|
|
|
|
// Time (secs) before first keepalive probe; between successful probes.
|
|
|
|
int32_t mTCPKeepaliveShortLivedIdleTimeS;
|
|
|
|
|
|
|
|
// True if TCP keepalive is enabled for long-lived conns.
|
|
|
|
bool mTCPKeepaliveLongLivedEnabled;
|
|
|
|
// Time (secs) before first keepalive probe; between successful probes.
|
|
|
|
int32_t mTCPKeepaliveLongLivedIdleTimeS;
|
|
|
|
|
2014-10-24 13:19:40 -07:00
|
|
|
// if true, generate NS_ERROR_PARTIAL_TRANSFER for h1 responses with
|
|
|
|
// incorrect content lengths or malformed chunked encodings
|
2015-02-24 16:16:00 -08:00
|
|
|
FrameCheckLevel mEnforceH1Framing;
|
2014-10-24 13:19:40 -07:00
|
|
|
|
2013-04-15 05:50:35 -07:00
|
|
|
private:
|
|
|
|
// For Rate Pacing Certain Network Events. Only assign this pointer on
|
|
|
|
// socket thread.
|
|
|
|
void MakeNewRequestTokenBucket();
|
2014-01-07 14:05:56 -08:00
|
|
|
nsRefPtr<EventTokenBucket> mRequestTokenBucket;
|
2013-04-15 05:50:35 -07:00
|
|
|
|
|
|
|
public:
|
|
|
|
// Socket thread only
|
2014-01-07 14:05:56 -08:00
|
|
|
nsresult SubmitPacedRequest(ATokenBucketEvent *event,
|
2013-04-15 05:50:35 -07:00
|
|
|
nsICancelable **cancel)
|
|
|
|
{
|
|
|
|
if (!mRequestTokenBucket)
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
return mRequestTokenBucket->SubmitEvent(event, cancel);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Socket thread only
|
2014-01-07 14:05:56 -08:00
|
|
|
void SetRequestTokenBucket(EventTokenBucket *aTokenBucket)
|
2013-04-15 05:50:35 -07:00
|
|
|
{
|
|
|
|
mRequestTokenBucket = aTokenBucket;
|
|
|
|
}
|
2013-07-11 08:39:36 -07:00
|
|
|
|
|
|
|
private:
|
2014-01-07 14:05:56 -08:00
|
|
|
nsRefPtr<Tickler> mWifiTickler;
|
2013-07-11 08:39:36 -07:00
|
|
|
void TickleWifi(nsIInterfaceRequestor *cb);
|
2015-05-05 18:15:36 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsresult SpeculativeConnectInternal(nsIURI *aURI,
|
|
|
|
nsIInterfaceRequestor *aCallbacks,
|
|
|
|
bool anonymous);
|
2013-04-15 05:50:35 -07:00
|
|
|
};
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
extern nsHttpHandler *gHttpHandler;
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// nsHttpsHandler - thin wrapper to distinguish the HTTP handler from the
|
|
|
|
// HTTPS handler (even though they share the same impl).
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class nsHttpsHandler : public nsIHttpProtocolHandler
|
|
|
|
, public nsSupportsWeakReference
|
2012-04-25 05:54:42 -07:00
|
|
|
, public nsISpeculativeConnect
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-06-24 09:36:44 -07:00
|
|
|
virtual ~nsHttpsHandler() { }
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
|
|
|
// we basically just want to override GetScheme and GetDefaultPort...
|
|
|
|
// all other methods should be forwarded to the nsHttpHandler instance.
|
2013-05-16 06:30:42 -07:00
|
|
|
|
2013-07-18 19:24:13 -07:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_NSIPROTOCOLHANDLER
|
|
|
|
NS_FORWARD_NSIPROXIEDPROTOCOLHANDLER (gHttpHandler->)
|
|
|
|
NS_FORWARD_NSIHTTPPROTOCOLHANDLER (gHttpHandler->)
|
2012-04-25 05:54:42 -07:00
|
|
|
NS_FORWARD_NSISPECULATIVECONNECT (gHttpHandler->)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsHttpsHandler() { }
|
|
|
|
|
|
|
|
nsresult Init();
|
|
|
|
};
|
|
|
|
|
2014-01-07 14:05:56 -08:00
|
|
|
}} // namespace mozilla::net
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif // nsHttpHandler_h__
|