mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-11 01:57:00 +00:00
Bug 995070 - Add preference to send 'Prefer: Safe' header as defined by draft-nottingham-safe-hint-01. r=mcmanus
This commit is contained in:
parent
ba8b77a271
commit
8fa43a4630
@ -62,6 +62,7 @@ HTTP_ATOM(Location, "Location")
|
||||
HTTP_ATOM(Max_Forwards, "Max-Forwards")
|
||||
HTTP_ATOM(Overwrite, "Overwrite")
|
||||
HTTP_ATOM(Pragma, "Pragma")
|
||||
HTTP_ATOM(Prefer, "Prefer")
|
||||
HTTP_ATOM(Proxy_Authenticate, "Proxy-Authenticate")
|
||||
HTTP_ATOM(Proxy_Authorization, "Proxy-Authorization")
|
||||
HTTP_ATOM(Proxy_Connection, "Proxy-Connection")
|
||||
|
@ -86,6 +86,7 @@ extern PRThread *gSocketThread;
|
||||
#define DONOTTRACK_VALUE_UNSET 2
|
||||
#define TELEMETRY_ENABLED "toolkit.telemetry.enabled"
|
||||
#define ALLOW_EXPERIMENTS "network.allow-experiments"
|
||||
#define SAFE_HINT_HEADER_VALUE "safeHint.enabled"
|
||||
|
||||
#define UA_PREF(_pref) UA_PREF_PREFIX _pref
|
||||
#define HTTP_PREF(_pref) HTTP_PREF_PREFIX _pref
|
||||
@ -172,6 +173,7 @@ nsHttpHandler::nsHttpHandler()
|
||||
, mEnablePersistentHttpsCaching(false)
|
||||
, mDoNotTrackEnabled(false)
|
||||
, mDoNotTrackValue(1)
|
||||
, mSafeHintEnabled(false)
|
||||
, mTelemetryEnabled(false)
|
||||
, mAllowExperiments(true)
|
||||
, mHandlerActive(false)
|
||||
@ -270,6 +272,7 @@ nsHttpHandler::Init()
|
||||
prefBranch->AddObserver(TELEMETRY_ENABLED, this, true);
|
||||
prefBranch->AddObserver(HTTP_PREF("tcp_keepalive.short_lived_connections"), this, true);
|
||||
prefBranch->AddObserver(HTTP_PREF("tcp_keepalive.long_lived_connections"), this, true);
|
||||
prefBranch->AddObserver(SAFE_HINT_HEADER_VALUE, this, true);
|
||||
PrefsChanged(prefBranch, nullptr);
|
||||
}
|
||||
|
||||
@ -417,6 +420,11 @@ nsHttpHandler::AddStandardRequestHeaders(nsHttpHeaderArray *request)
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// add the "Send Hint" header
|
||||
if (mSafeHintEnabled) {
|
||||
rv = request->SetHeader(nsHttp::Prefer, NS_LITERAL_CSTRING("safe"));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1293,6 +1301,15 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
|
||||
}
|
||||
}
|
||||
|
||||
// Hint option
|
||||
if (PREF_CHANGED(SAFE_HINT_HEADER_VALUE)) {
|
||||
cVar = false;
|
||||
rv = prefs->GetBoolPref(SAFE_HINT_HEADER_VALUE, &cVar);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mSafeHintEnabled = cVar;
|
||||
}
|
||||
}
|
||||
|
||||
// toggle to true anytime a token bucket related pref is changed.. that
|
||||
// includes telemetry and allow-experiments because of the abtest profile
|
||||
bool requestTokenBucketUpdated = false;
|
||||
|
@ -434,6 +434,9 @@ private:
|
||||
bool mDoNotTrackEnabled;
|
||||
uint8_t mDoNotTrackValue;
|
||||
|
||||
// for broadcasting safe hint;
|
||||
bool mSafeHintEnabled;
|
||||
|
||||
// Whether telemetry is reported or not
|
||||
uint32_t mTelemetryEnabled : 1;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user