File tree Expand file tree Collapse file tree 1 file changed +42
-14
lines changed Expand file tree Collapse file tree 1 file changed +42
-14
lines changed Original file line number Diff line number Diff line change 2
2
(:use
3
3
[clojure test])
4
4
(:require
5
- [clojure.java.io :as io]
6
5
[aleph
7
6
[http :as http]
8
7
[netty :as netty]
11
10
[manifold.deferred :as d]
12
11
[manifold.stream :as s])
13
12
(:import
14
- [java.util.concurrent
15
- Executors]
16
- [java.io
17
- File
18
- ByteArrayInputStream]
19
- [java.util.zip
20
- GZIPInputStream
21
- ZipException]
22
- [java.util.concurrent
23
- TimeoutException]
24
- [aleph.utils
25
- ConnectionTimeoutException
26
- RequestTimeoutException]))
13
+ (java.io
14
+ File)
15
+ (java.util.zip
16
+ GZIPInputStream
17
+ ZipException)
18
+ (java.util.concurrent
19
+ TimeoutException)
20
+ (aleph.utils
21
+ ConnectionTimeoutException
22
+ RequestTimeoutException)
23
+ (io.netty.channel
24
+ ChannelHandlerContext
25
+ ChannelOutboundHandlerAdapter
26
+ ChannelPipeline
27
+ ChannelPromise)
28
+ (io.netty.handler.codec.http
29
+ HttpMessage)))
27
30
28
31
; ;;
29
32
450
453
(Thread/sleep (* 1000 60 ))
451
454
(println " stopping server" )
452
455
(.close ^java.io.Closeable server)))
456
+
457
+
458
+ (deftest test-pipeline-header-alteration
459
+ (let [test-header-name " aleph-test"
460
+ test-header-val " MOOP" ]
461
+ (with-server (http/start-server
462
+ basic-handler
463
+ {:port port
464
+ :pipeline-transform
465
+ (fn [^ChannelPipeline pipeline]
466
+ (.addBefore pipeline
467
+ " request-handler"
468
+ " test-header-inserter"
469
+ (proxy [ChannelOutboundHandlerAdapter] []
470
+ (write [^ChannelHandlerContext ctx
471
+ ^Object msg
472
+ ^ChannelPromise p]
473
+ (when (instance? HttpMessage msg)
474
+ (let [^HttpMessage http-msg msg]
475
+ (-> http-msg
476
+ (.headers )
477
+ (.set test-header-name test-header-val))))
478
+ (.write ctx msg p)))))})
479
+ (let [resp @(http-get (str " http://localhost:" port " /string" ))]
480
+ (is (= test-header-val (get (:headers resp) test-header-name)))))))
You can’t perform that action at this time.
0 commit comments