Fix ODR violations in http_constants.h
See https://abseil.io/tips/140 for details.
PiperOrigin-RevId: 360231446
Change-Id: I26c273cdfddac3c3f9a19378b719d655361e449a
diff --git a/quic/core/http/http_constants.cc b/quic/core/http/http_constants.cc
index d7281a3..dbf49df 100644
--- a/quic/core/http/http_constants.cc
+++ b/quic/core/http/http_constants.cc
@@ -22,6 +22,8 @@
return absl::StrCat("UNSUPPORTED_SETTINGS_TYPE(", identifier, ")");
}
+const absl::string_view kUserAgentHeaderName = "user-agent";
+
#undef RETURN_STRING_LITERAL // undef for jumbo builds
} // namespace quic
diff --git a/quic/core/http/http_constants.h b/quic/core/http/http_constants.h
index 27ce56b..afb18d6 100644
--- a/quic/core/http/http_constants.h
+++ b/quic/core/http/http_constants.h
@@ -8,22 +8,24 @@
#include <cstdint>
#include <string>
+#include "absl/strings/string_view.h"
#include "quic/core/quic_types.h"
#include "quic/platform/api/quic_export.h"
namespace quic {
// Unidirectional stream types.
-
-// https://quicwg.org/base-drafts/draft-ietf-quic-http.html#unidirectional-streams
-const uint64_t kControlStream = 0x00;
-const uint64_t kServerPushStream = 0x01;
-// https://quicwg.org/base-drafts/draft-ietf-quic-qpack.html#enc-dec-stream-def
-const uint64_t kQpackEncoderStream = 0x02;
-const uint64_t kQpackDecoderStream = 0x03;
+enum : uint64_t {
+ // https://quicwg.org/base-drafts/draft-ietf-quic-http.html#unidirectional-streams
+ kControlStream = 0x00,
+ kServerPushStream = 0x01,
+ // https://quicwg.org/base-drafts/draft-ietf-quic-qpack.html#enc-dec-stream-def
+ kQpackEncoderStream = 0x02,
+ kQpackDecoderStream = 0x03,
+};
// This includes control stream, QPACK encoder stream, and QPACK decoder stream.
-const QuicStreamCount kHttp3StaticUnidirectionalStreamCount = 3;
+enum : QuicStreamCount { kHttp3StaticUnidirectionalStreamCount = 3 };
// HTTP/3 and QPACK settings identifiers.
// https://quicwg.org/base-drafts/draft-ietf-quic-http.html#settings-parameters
@@ -44,17 +46,22 @@
// Default maximum dynamic table capacity, communicated via
// SETTINGS_QPACK_MAX_TABLE_CAPACITY.
-const QuicByteCount kDefaultQpackMaxDynamicTableCapacity = 64 * 1024; // 64 KB
+enum : QuicByteCount {
+ kDefaultQpackMaxDynamicTableCapacity = 64 * 1024 // 64 KB
+};
// Default limit on the size of uncompressed headers,
// communicated via SETTINGS_MAX_HEADER_LIST_SIZE.
-const QuicByteCount kDefaultMaxUncompressedHeaderSize = 16 * 1024; // 16 KB
+enum : QuicByteCount {
+ kDefaultMaxUncompressedHeaderSize = 16 * 1024 // 16 KB
+};
// Default limit on number of blocked streams, communicated via
// SETTINGS_QPACK_BLOCKED_STREAMS.
-const uint64_t kDefaultMaximumBlockedStreams = 100;
+enum : uint64_t { kDefaultMaximumBlockedStreams = 100 };
-const char kUserAgentHeaderName[] = "user-agent";
+QUIC_EXPORT_PRIVATE ABSL_CONST_INIT extern const absl::string_view
+ kUserAgentHeaderName;
} // namespace quic