Extend WebTransport error code space to 32-bit.
This is backwards-compatible (the receiver always has to handle error codes outside of WebTransport range anyways), meaning we do not need to gate this via version negotiation.
PiperOrigin-RevId: 531176993
diff --git a/quiche/quic/core/http/end_to_end_test.cc b/quiche/quic/core/http/end_to_end_test.cc
index 1662a69..fd71300 100644
--- a/quiche/quic/core/http/end_to_end_test.cc
+++ b/quiche/quic/core/http/end_to_end_test.cc
@@ -6964,12 +6964,12 @@
QuicStreamId id2 = stream->GetStreamId();
ASSERT_TRUE(stream != nullptr);
QUICHE_EXPECT_OK(quiche::WriteIntoStream(*stream, "test"));
- stream->SendStopSending(24);
+ stream->SendStopSending(100024);
std::array<std::string, 2> expected_log = {
absl::StrCat("Received reset for stream ", id1, " with error code 42"),
absl::StrCat("Received stop sending for stream ", id2,
- " with error code 24"),
+ " with error code 100024"),
};
client_->WaitUntil(2000, [this, &expected_log]() {
return received_webtransport_unidirectional_streams_.size() >=
diff --git a/quiche/quic/core/http/web_transport_http3.cc b/quiche/quic/core/http/web_transport_http3.cc
index 7a5fd07..f1c922b 100644
--- a/quiche/quic/core/http/web_transport_http3.cc
+++ b/quiche/quic/core/http/web_transport_http3.cc
@@ -436,7 +436,7 @@
namespace {
constexpr uint64_t kWebTransportMappedErrorCodeFirst = 0x52e4a40fa8db;
-constexpr uint64_t kWebTransportMappedErrorCodeLast = 0x52e4a40fa9e2;
+constexpr uint64_t kWebTransportMappedErrorCodeLast = 0x52e5ac983162;
constexpr WebTransportStreamError kDefaultWebTransportError = 0;
} // namespace
@@ -454,7 +454,8 @@
uint64_t shifted = http3_error_code - kWebTransportMappedErrorCodeFirst;
uint64_t result = shifted - shifted / 0x1f;
- QUICHE_DCHECK_LE(result, std::numeric_limits<uint8_t>::max());
+ QUICHE_DCHECK_LE(result,
+ std::numeric_limits<webtransport::StreamErrorCode>::max());
return static_cast<WebTransportStreamError>(result);
}
diff --git a/quiche/quic/core/http/web_transport_http3_test.cc b/quiche/quic/core/http/web_transport_http3_test.cc
index 87cd0d3..be8cfdd 100644
--- a/quiche/quic/core/http/web_transport_http3_test.cc
+++ b/quiche/quic/core/http/web_transport_http3_test.cc
@@ -18,6 +18,7 @@
TEST(WebTransportHttp3Test, ErrorCodesToHttp3) {
EXPECT_EQ(0x52e4a40fa8dbu, WebTransportErrorToHttp3(0x00));
EXPECT_EQ(0x52e4a40fa9e2u, WebTransportErrorToHttp3(0xff));
+ EXPECT_EQ(0x52e5ac983162u, WebTransportErrorToHttp3(0xffffffff));
EXPECT_EQ(0x52e4a40fa8f7u, WebTransportErrorToHttp3(0x1c));
EXPECT_EQ(0x52e4a40fa8f8u, WebTransportErrorToHttp3(0x1d));
@@ -28,6 +29,7 @@
TEST(WebTransportHttp3Test, ErrorCodesToWebTransport) {
EXPECT_THAT(Http3ErrorToWebTransport(0x52e4a40fa8db), Optional(0x00));
EXPECT_THAT(Http3ErrorToWebTransport(0x52e4a40fa9e2), Optional(0xff));
+ EXPECT_THAT(Http3ErrorToWebTransport(0x52e5ac983162u), Optional(0xffffffff));
EXPECT_THAT(Http3ErrorToWebTransport(0x52e4a40fa8f7), Optional(0x1cu));
EXPECT_THAT(Http3ErrorToWebTransport(0x52e4a40fa8f8), Optional(0x1du));
@@ -40,11 +42,18 @@
}
TEST(WebTransportHttp3Test, ErrorCodeRoundTrip) {
- for (int error = 0; error < 256; error++) {
+ for (int error = 0; error <= 65536; error++) {
uint64_t http_error = WebTransportErrorToHttp3(error);
absl::optional<WebTransportStreamError> mapped_back =
quic::Http3ErrorToWebTransport(http_error);
- EXPECT_THAT(mapped_back, Optional(error));
+ ASSERT_THAT(mapped_back, Optional(error));
+ }
+ for (int64_t error = 0; error < std::numeric_limits<uint32_t>::max();
+ error += 65537) {
+ uint64_t http_error = WebTransportErrorToHttp3(error);
+ absl::optional<WebTransportStreamError> mapped_back =
+ quic::Http3ErrorToWebTransport(http_error);
+ ASSERT_THAT(mapped_back, Optional(error));
}
}
diff --git a/quiche/quic/core/quic_types.h b/quiche/quic/core/quic_types.h
index b2a100b..961e904 100644
--- a/quiche/quic/core/quic_types.h
+++ b/quiche/quic/core/quic_types.h
@@ -23,6 +23,7 @@
#include "quiche/quic/platform/api/quic_export.h"
#include "quiche/quic/platform/api/quic_flags.h"
#include "quiche/common/quiche_endian.h"
+#include "quiche/web_transport/web_transport.h"
namespace quic {
@@ -52,10 +53,10 @@
// WebTransport session IDs are stream IDs.
using WebTransportSessionId = uint64_t;
-// WebTransport stream reset codes are 8-bit.
-using WebTransportStreamError = uint8_t;
+// WebTransport stream reset codes are 32-bit.
+using WebTransportStreamError = ::webtransport::StreamErrorCode;
// WebTransport session error codes are 32-bit.
-using WebTransportSessionError = uint32_t;
+using WebTransportSessionError = ::webtransport::SessionErrorCode;
enum : size_t { kQuicPathFrameBufferSize = 8 };
using QuicPathFrameBuffer = std::array<uint8_t, kQuicPathFrameBufferSize>;
diff --git a/quiche/web_transport/web_transport.h b/quiche/web_transport/web_transport.h
index 7ea0085..70bb36f 100644
--- a/quiche/web_transport/web_transport.h
+++ b/quiche/web_transport/web_transport.h
@@ -30,7 +30,7 @@
using StreamId = uint32_t;
// Application-specific error code used for resetting either the read or the
// write half of the stream.
-using StreamErrorCode = uint8_t;
+using StreamErrorCode = uint32_t;
// Application-specific error code used for closing a WebTransport session.
using SessionErrorCode = uint32_t;