Skip to content

Commit 25355f8

Browse files
committed
Fail when giving both use-h2c? true *and* and ssl-context
1 parent c714433 commit 25355f8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/aleph/http/server.clj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,10 @@
764764
(some #{:http2} http-versions))
765765
(throw (IllegalArgumentException. "HTTP/2 requires ssl-context to be given or use-h2c? to be true.")))
766766

767+
(when (and ssl-context
768+
use-h2c?)
769+
(throw (IllegalArgumentException. "use-h2c? must not be true when ssl-context is given.")))
770+
767771
(netty/start-server
768772
{:pipeline-builder pipeline-builder
769773
:bootstrap-transform bootstrap-transform

test/aleph/http_test.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,9 +1410,10 @@
14101410
{:use-h2c? true
14111411
:http-versions [:http2]})]
14121412
(is (= :started result))))
1413-
(testing "HTTP/2 with ssl-context *and* with h2c (which has no effect then)"
1413+
(testing "HTTP/2 with ssl-context *and* with h2c"
14141414
(let [result (try-start-server
14151415
{:use-h2c? true
14161416
:http-versions [:http2]
14171417
:ssl-context test-ssl/server-ssl-context-opts})]
1418-
(is (= :started result)))))
1418+
(is (instance? IllegalArgumentException result))
1419+
(is (= "use-h2c? must not be true when ssl-context is given." (ex-message result))))))

0 commit comments

Comments
 (0)