Implement QUIC ALPN selection on the server side.
This also fixes the bugs in client side found by a full custom ALPN test, and removes a tautological check from server-side ALPN parser.
gfe-relnote: n/a (protected by disabled quic_tls flag)
PiperOrigin-RevId: 266319592
Change-Id: I9e06b383abe187286f31d3cbce8be99e9370c9f2
diff --git a/quic/core/quic_session.h b/quic/core/quic_session.h
index d5ddc69..16c7efc 100644
--- a/quic/core/quic_session.h
+++ b/quic/core/quic_session.h
@@ -460,12 +460,21 @@
}
// Returns the ALPN values to negotiate on this session.
- virtual std::vector<std::string> GetAlpnsToOffer() {
+ virtual std::vector<std::string> GetAlpnsToOffer() const {
// TODO(vasilvv): this currently sets HTTP/3 by default. Switch all
// non-HTTP applications to appropriate ALPNs.
return std::vector<std::string>({AlpnForVersion(connection()->version())});
}
+ // Provided a list of ALPNs offered by the client, selects an ALPN from the
+ // list, or alpns.end() if none of the ALPNs are acceptable.
+ virtual std::vector<QuicStringPiece>::const_iterator SelectAlpn(
+ const std::vector<QuicStringPiece>& alpns) const;
+
+ // Called when the ALPN of the connection is established for a connection that
+ // uses TLS handshake.
+ virtual void OnAlpnSelected(QuicStringPiece alpn);
+
protected:
using StreamMap = QuicSmallMap<QuicStreamId, std::unique_ptr<QuicStream>, 10>;