Skip to content

Commit 8751d05

Browse files
committed
Add :aleph/channel to server's ring request map
This makes `aleph.http.core/ring-request-ssl-session` work with HTTP/2 requests, too, since we no longer have to rely on the HTTP/1-only NettyRequest's `ch` field. However, since for HTTP/2 the `SslHandler` lives on the connection channel rather than the request's stream channel, we have to change `channel-ssl-session` to recur the channel ancestor chain to find it now.
1 parent 6379fee commit 8751d05

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/aleph/http/core.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@
242242
:server-name (netty/channel-server-name ch)
243243
:server-port (netty/channel-server-port ch)
244244
:remote-addr (netty/channel-remote-address ch)
245+
:aleph/channel ch
245246
:aleph/request-arrived request-arrived
246247
:protocol "HTTP/1.1")
247248

@@ -267,8 +268,8 @@
267268
[rsp destroy-conn? body]
268269
(->NettyResponse rsp destroy-conn? body))
269270

270-
(defn ring-request-ssl-session [^NettyRequest req]
271-
(netty/channel-ssl-session (.ch req)))
271+
(defn ring-request-ssl-session [req]
272+
(netty/channel-ssl-session (:aleph/channel req)))
272273

273274
;;;
274275

src/aleph/http/http2.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,7 @@
822822

823823
:protocol "HTTP/2.0"
824824

825+
:aleph/channel ch
825826
:aleph/writable? writable?
826827
:aleph/h2-exception h2-exception
827828
:aleph/keep-alive? true ; not applicable to HTTP/2, but here for compatibility

src/aleph/netty.clj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,11 +1190,12 @@
11901190
(partial coerce-ssl-context ssl-client-context))
11911191

11921192
(defn ^:no-doc channel-ssl-session [^Channel ch]
1193-
(some-> ch
1194-
^ChannelPipeline (.pipeline)
1195-
^SslHandler (.get SslHandler)
1196-
.engine
1197-
.getSession))
1193+
(or (some-> ch
1194+
^ChannelPipeline (.pipeline)
1195+
^SslHandler (.get SslHandler)
1196+
.engine
1197+
.getSession)
1198+
(recur (.parent ch))))
11981199

11991200
(defn ^:no-doc ssl-handshake-error? [^Throwable ex]
12001201
(and (instance? DecoderException ex)

0 commit comments

Comments
 (0)