Skip to content

Commit 1c13623

Browse files
DerGuteMoritzalexander-yakushev
authored andcommitted
Add test cases for HttpObjectAggregator support
1 parent 33d8d3f commit 1c13623

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

test/aleph/http_test.clj

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
(:import
1616
(aleph.utils ConnectionTimeoutException RequestTimeoutException)
1717
(io.netty.channel ChannelHandlerContext ChannelOutboundHandlerAdapter ChannelPipeline ChannelPromise)
18-
(io.netty.handler.codec.http HttpMessage)
18+
(io.netty.handler.codec.http HttpMessage HttpObjectAggregator)
1919
(java.io File)
2020
(java.util.concurrent TimeoutException)
2121
(java.util.zip GZIPInputStream ZipException)))
@@ -570,3 +570,41 @@
570570
(.write ctx msg p)))))})
571571
(let [resp @(http-get (str "http://localhost:" port "/string"))]
572572
(is (= test-header-val (get (:headers resp) test-header-name)))))))
573+
574+
(defn add-http-object-aggregator [^ChannelPipeline pipeline]
575+
(let [max-content-length 5]
576+
(.addBefore pipeline
577+
"request-handler"
578+
"http-object-aggregator"
579+
(HttpObjectAggregator. max-content-length))))
580+
581+
(deftest test-http-object-aggregator-support
582+
(with-server (http/start-server
583+
basic-handler
584+
{:port port
585+
:pipeline-transform add-http-object-aggregator})
586+
(let [rsp @(http-put (str "http://localhost:" port "/echo")
587+
{:body "hello"})]
588+
(is (= "hello" (bs/to-string (:body rsp))))
589+
(is (= 200 (:status rsp))))
590+
591+
(let [rsp @(http-put (str "http://localhost:" port "/echo")
592+
{:body "hello, world!"})]
593+
(is (= 413 (:status rsp)))
594+
(is (empty? (bs/to-string (:body rsp)))))))
595+
596+
(deftest test-http-object-aggregator-raw-stream-support
597+
(with-server (http/start-server
598+
basic-handler
599+
{:port port
600+
:raw-stream? true
601+
:pipeline-transform add-http-object-aggregator})
602+
(let [rsp @(http-put (str "http://localhost:" port "/echo")
603+
{:body "hello"})]
604+
(is (= "hello" (bs/to-string (:body rsp))))
605+
(is (= 200 (:status rsp))))
606+
607+
(let [rsp @(http-put (str "http://localhost:" port "/echo")
608+
{:body "hello, world!"})]
609+
(is (= 413 (:status rsp)))
610+
(is (empty? (bs/to-string (:body rsp)))))))

0 commit comments

Comments
 (0)