|
38 | 38 | TooLongFrameException]
|
39 | 39 | [io.netty.handler.codec.http
|
40 | 40 | DefaultFullHttpResponse
|
| 41 | + FullHttpRequest |
41 | 42 | HttpContent HttpHeaders HttpUtil
|
42 | 43 | HttpContentCompressor
|
43 | 44 | HttpRequest HttpResponse
|
|
272 | 273 | (handle-request ctx req s))
|
273 | 274 | (reset! request req)))
|
274 | 275 |
|
| 276 | + process-full-request |
| 277 | + (fn [ctx ^FullHttpRequest req] |
| 278 | + ;; HttpObjectAggregator disables chunked encoding, no need to check for it. |
| 279 | + (let [content (.content req) |
| 280 | + body (when (pos? (.readableBytes content)) |
| 281 | + (netty/buf->array content))] |
| 282 | + ;; Don't release content as it will happen automatically once whole |
| 283 | + ;; request is released. |
| 284 | + (handle-request ctx req body))) |
| 285 | + |
275 | 286 | process-last-content
|
276 | 287 | (fn [ctx ^HttpContent msg]
|
277 | 288 | (let [content (.content msg)]
|
|
350 | 361 | ([_ ctx msg]
|
351 | 362 | (cond
|
352 | 363 |
|
| 364 | + ;; Happens when io.netty.handler.codec.http.HttpObjectAggregator is part of the pipeline. |
| 365 | + (instance? FullHttpRequest msg) |
| 366 | + (if (invalid-request? msg) |
| 367 | + (reject-invalid-request ctx msg) |
| 368 | + (process-full-request ctx msg)) |
| 369 | + |
353 | 370 | (instance? HttpRequest msg)
|
354 | 371 | (if (invalid-request? msg)
|
355 | 372 | (reject-invalid-request ctx msg)
|
|
398 | 415 | ([_ ctx msg]
|
399 | 416 | (cond
|
400 | 417 |
|
| 418 | + ;; Happens when io.netty.handler.codec.http.HttpObjectAggregator is part of the pipeline. |
| 419 | + (instance? FullHttpRequest msg) |
| 420 | + (if (invalid-request? msg) |
| 421 | + (reject-invalid-request ctx msg) |
| 422 | + (let [^FullHttpRequest req msg |
| 423 | + content (.content req) |
| 424 | + ch (netty/channel ctx) |
| 425 | + s (netty/source ch)] |
| 426 | + (when-not (zero? (.readableBytes content)) |
| 427 | + ;; Retain the content of FullHttpRequest one extra time to |
| 428 | + ;; compensate for it being released together with the request. |
| 429 | + (netty/put! ch s (netty/acquire content))) |
| 430 | + (s/close! s) |
| 431 | + (handle-request ctx req s))) |
| 432 | + |
401 | 433 | (instance? HttpRequest msg)
|
402 | 434 | (if (invalid-request? msg)
|
403 | 435 | (reject-invalid-request ctx msg)
|
|
0 commit comments