File tree 2 files changed +31
-1
lines changed
2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 938
938
" Creates a default config for Application-Layer Protocol Negotiation (ALPN),
939
939
which TLS uses to negotiate which HTTP version to use during the handshake.
940
940
941
- Takes a vector of HTTP versions, in order of preference. E.g., `[:http2 :http1]`"
941
+ Takes a vector of HTTP versions, in order of preference. E.g., `[:http2 :http1]`
942
+
943
+ Note that the returned config uses `SelectorFailureBehavior.NO_ADVERTISE`[1] and
944
+ `SelectedListenerFailureBehavior.ACCEPT`[2] since these are the only failure behaviors
945
+ supported by all SSL providers. See their documentation for details. One important
946
+ consequence of this is that it's not possible to completely opt out of HTTP/1.1 by way of
947
+ only specifying `[:http2]`.
948
+
949
+ 1: https://netty.io/4.1/api/io/netty/handler/ssl/ApplicationProtocolConfig.SelectorFailureBehavior.html#NO_ADVERTISE
950
+ 2: https://netty.io/4.1/api/io/netty/handler/ssl/ApplicationProtocolConfig.SelectedListenerFailureBehavior.html#ACCEPT"
942
951
^ApplicationProtocolConfig
943
952
[protocols]
944
953
(ApplicationProtocolConfig.
Original file line number Diff line number Diff line change 1619
1619
(is (instance? IllegalArgumentException result))
1620
1620
(is (= " force-h2c? may only be true when HTTP/2 is enabled." (ex-message result))))))))
1621
1621
1622
+ (deftest http2-only-client-connecting-to-http1-only-server
1623
+ (testing " No ALPN config, desiring only HTTP/2 but the server only allows HTTP/1"
1624
+ (with-http1-server echo-handler http1-ssl-server-options
1625
+ (with-redefs [*use-tls-requests* true ]
1626
+ (let [result (try-request-with-pool
1627
+ {:connection-options
1628
+ {:http-versions [:http2 ]
1629
+ :ssl-context test-ssl/client-ssl-context-opts}})]
1630
+ (is (= :success result) " succeeds due to the default failure behaviors (see docstring of `application-protocol-config`)" ))))))
1631
+
1632
+
1633
+ (deftest http1-only-client-connecting-to-http2-only-server
1634
+ (testing " No ALPN config, desiring only HTTP/1.1 but the server only allows HTTP/2"
1635
+ (with-http2-server echo-handler {}
1636
+ (with-redefs [*use-tls-requests* true ]
1637
+ (let [result (try-request-with-pool
1638
+ {:connection-options
1639
+ {:http-versions [:http1 ]
1640
+ :ssl-context test-ssl/client-ssl-context-opts}})]
1641
+ (is (= :success result) " succeeds due to the default failure behaviors (see docstring of `application-protocol-config`)" ))))))
1642
+
1622
1643
1623
1644
(deftest test-in-flight-request-cancellation
1624
1645
(let [conn-established (promise )
You can’t perform that action at this time.
0 commit comments