|
15 | 15 | (:import
|
16 | 16 | (aleph.utils ConnectionTimeoutException RequestTimeoutException)
|
17 | 17 | (io.netty.channel ChannelHandlerContext ChannelOutboundHandlerAdapter ChannelPipeline ChannelPromise)
|
18 |
| - (io.netty.handler.codec.http HttpMessage) |
| 18 | + (io.netty.handler.codec.http HttpMessage HttpObjectAggregator) |
19 | 19 | (java.io File)
|
20 | 20 | (java.util.concurrent TimeoutException)
|
21 | 21 | (java.util.zip GZIPInputStream ZipException)))
|
|
570 | 570 | (.write ctx msg p)))))})
|
571 | 571 | (let [resp @(http-get (str "http://localhost:" port "/string"))]
|
572 | 572 | (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