File tree Expand file tree Collapse file tree 3 files changed +31
-12
lines changed Expand file tree Collapse file tree 3 files changed +31
-12
lines changed Original file line number Diff line number Diff line change 100
100
nil ))
101
101
(no-url req))))
102
102
103
+ (defn exception-handler [ctx ex response-stream]
104
+ (cond
105
+ ; ; could happens when io.netty.handler.codec.http.HttpObjectAggregator
106
+ ; ; is part of the pipeline
107
+ (instance? TooLongFrameException ex)
108
+ (s/put! response-stream ex)
109
+
110
+ ; ; when SSL handshake failed
111
+ (http/ssl-handshake-error? ex)
112
+ (let [^Throwable handshake-error (.getCause ^Throwable ex)]
113
+ (s/put! response-stream handshake-error))
114
+
115
+ (not (instance? IOException ex))
116
+ (log/warn ex " error in HTTP client" )))
117
+
103
118
(defn raw-client-handler
104
119
[response-stream buffer-capacity]
105
120
(let [stream (atom nil )
117
132
118
133
:exception-caught
119
134
([_ ctx ex]
120
- (when-not (instance? IOException ex)
121
- (log/warn ex " error in HTTP client" )))
135
+ (exception-handler ctx ex response-stream))
122
136
123
137
:channel-inactive
124
138
([_ ctx]
169
183
170
184
:exception-caught
171
185
([_ ctx ex]
172
- (cond
173
- ; could happens when io.netty.handler.codec.http.HttpObjectAggregator
174
- ; is part of the pipeline
175
- (instance? TooLongFrameException ex)
176
- (s/put! response-stream ex)
177
-
178
- (not (instance? IOException ex))
179
- (log/warn ex " error in HTTP client" )))
186
+ (exception-handler ctx ex response-stream))
180
187
181
188
:channel-inactive
182
189
([_ ctx]
Original file line number Diff line number Diff line change 23
23
ByteBuf]
24
24
[java.nio
25
25
ByteBuffer]
26
+ [io.netty.handler.codec DecoderException]
26
27
[io.netty.handler.codec.http
27
28
DefaultHttpRequest DefaultLastHttpContent
28
29
DefaultHttpResponse DefaultFullHttpRequest
61
62
ConcurrentLinkedQueue
62
63
TimeUnit]
63
64
[java.util.concurrent.atomic
64
- AtomicBoolean]))
65
+ AtomicBoolean]
66
+ [javax.net.ssl SSLHandshakeException]))
65
67
66
68
(def non-standard-keys
67
69
(let [ks [" Content-MD5"
682
684
(when (and (identical? ::ping-timeout v)
683
685
(.isOpen ^Channel (.channel ctx)))
684
686
(netty/close ctx))))))))
687
+
688
+ (defn ssl-handshake-error? [^Throwable ex]
689
+ (and (instance? DecoderException ex)
690
+ (instance? SSLHandshakeException (.getCause ex))))
Original file line number Diff line number Diff line change 209
209
(invalid-value-response req rsp))))))))))))
210
210
211
211
(defn exception-handler [ctx ex]
212
- (when-not (instance? IOException ex)
212
+ (cond
213
+ ; ; do not need to log an entire stack trace when SSL handshake failed
214
+ (http/ssl-handshake-error? ex)
215
+ (log/warn " SSL handshake failure:"
216
+ (.getMessage ^Throwable (.getCause ^Throwable ex)))
217
+
218
+ (not (instance? IOException ex))
213
219
(log/warn ex " error in HTTP server" )))
214
220
215
221
(defn invalid-request? [^HttpRequest req]
You can’t perform that action at this time.
0 commit comments