summaryrefslogtreecommitdiffstats
path: root/netwerk/protocol/http/nsHttpChannel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'netwerk/protocol/http/nsHttpChannel.cpp')
-rw-r--r--netwerk/protocol/http/nsHttpChannel.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp
index 96e61e4fb8..4428b72426 100644
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -15,11 +15,13 @@
#include "mozilla/glean/GleanMetrics.h"
#include "mozilla/StoragePrincipalHelper.h"
+#include "nsCOMPtr.h"
#include "nsContentSecurityUtils.h"
#include "nsHttp.h"
#include "nsHttpChannel.h"
#include "nsHttpChannelAuthProvider.h"
#include "nsHttpHandler.h"
+#include "nsIStreamConverter.h"
#include "nsString.h"
#include "nsICacheStorageService.h"
#include "nsICacheStorage.h"
@@ -483,6 +485,25 @@ void nsHttpChannel::HandleContinueCancellingByURLClassifier(
ContinueCancellingByURLClassifier(aErrorCode);
}
+void nsHttpChannel::SetPriorityHeader() {
+ uint8_t urgency = nsHttpHandler::UrgencyFromCoSFlags(mClassOfService.Flags());
+ bool incremental = mClassOfService.Incremental();
+
+ nsPrintfCString value(
+ "%s", urgency != 3 ? nsPrintfCString("u=%d", urgency).get() : "");
+
+ if (incremental) {
+ if (!value.IsEmpty()) {
+ value.Append(", ");
+ }
+ value.Append("i");
+ }
+
+ if (!value.IsEmpty()) {
+ SetRequestHeader("Priority"_ns, value, false);
+ }
+}
+
nsresult nsHttpChannel::OnBeforeConnect() {
nsresult rv = NS_OK;
@@ -1202,6 +1223,10 @@ nsresult nsHttpChannel::SetupTransaction() {
mozilla::MutexAutoLock lock(mRCWNLock);
+ if (StaticPrefs::network_http_priority_header_enabled()) {
+ SetPriorityHeader();
+ }
+
// If we're racing cache with network, conditional or byte range header
// could be added in OnCacheEntryCheck. We cannot send conditional request
// without having the entry, so we need to remove the headers here and
@@ -1810,6 +1835,7 @@ nsresult nsHttpChannel::CallOnStartRequest() {
"converter in this case.");
mListener = listener;
mCompressListener = listener;
+
StoreHasAppliedConversion(true);
}
}
@@ -7664,6 +7690,7 @@ static nsLiteralCString ContentTypeToTelemetryLabel(nsHttpChannel* aChannel) {
return "proxy"_ns;
}
if (contentType.EqualsLiteral(APPLICATION_BROTLI) ||
+ contentType.EqualsLiteral(APPLICATION_ZSTD) ||
contentType.Find("zip") != kNotFound ||
contentType.Find("compress") != kNotFound) {
return "compressed"_ns;