Include non-default port in the origin field of the ACCEPT_CH frame in ALPS.
Protected by FLAGS_quic_reloadable_flag_quic_include_port_in_alps_origin.
PiperOrigin-RevId: 381847326
diff --git a/quic/core/quic_flags_list.h b/quic/core/quic_flags_list.h
index 74aa4a1..c4fc7e6 100644
--- a/quic/core/quic_flags_list.h
+++ b/quic/core/quic_flags_list.h
@@ -77,6 +77,8 @@
QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_enable_server_on_wire_ping, true)
// If true, ignore peer_max_ack_delay during handshake.
QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_ignore_peer_max_ack_delay_during_handshake, false)
+// If true, include non-default port in the origin field of the ACCEPT_CH frame in ALPS.
+QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_include_port_in_alps_origin, false)
// If true, include stream information in idle timeout connection close detail.
QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_add_stream_info_to_idle_close_detail, true)
// If true, increase the size of stream sequencer buffer block container on demand.
diff --git a/quic/core/tls_server_handshaker.cc b/quic/core/tls_server_handshaker.cc
index 65b9c3a..96dc4bf 100644
--- a/quic/core/tls_server_handshaker.cc
+++ b/quic/core/tls_server_handshaker.cc
@@ -34,6 +34,13 @@
namespace quic {
+namespace {
+
+// Default port for HTTP/3.
+uint16_t kDefaultPort = 443;
+
+} // namespace
+
TlsServerHandshaker::DefaultProofSourceHandle::DefaultProofSourceHandle(
TlsServerHandshaker* handshaker,
ProofSource* proof_source)
@@ -1015,6 +1022,15 @@
const std::string& hostname = crypto_negotiated_params_->sni;
std::string accept_ch_value = GetAcceptChValueForHostname(hostname);
std::string origin = absl::StrCat("https://", hostname);
+ if (GetQuicReloadableFlag(quic_include_port_in_alps_origin)) {
+ QUIC_RELOADABLE_FLAG_COUNT(quic_include_port_in_alps_origin);
+ uint16_t port = session()->self_address().port();
+ if (port != kDefaultPort) {
+ // This should be rare in production, but useful for test servers.
+ QUIC_CODE_COUNT(quic_server_alps_non_default_port);
+ absl::StrAppend(&origin, ":", port);
+ }
+ }
if (!accept_ch_value.empty()) {
AcceptChFrame frame{{{std::move(origin), std::move(accept_ch_value)}}};