eclipse-vertx / vert.x

Vert.x is a tool-kit for building reactive applications on the JVM
http://vertx.io
Other
14.31k stars 2.08k forks source link

Http Request stuck with malformed chunked encoding body #1621

Open mhstnsc opened 8 years ago

mhstnsc commented 8 years ago

I issue a request with missing \r\n after a chunk length. This is never received by my handler and the connection is not closed immediately (as opposed to a valid request).

Code to try https://github.com/mhstnsc/vertx-tests/blob/master/src/test/java/io/mhstnsc/vertx/test/web/ChunkedEncodingTest.java

i looked at the code a bit but i did not find exactly where is the chunked encoding handled.

mhstnsc commented 8 years ago

I updated the test.

Here is a dump from the test

2016-09-09 16:08:51,430 DEBUG [vert.x-eventloop-thread-2] LoggingHandler:71 - [id: 0xdaf6f8f4, L:/127.0.0.1:58962 - R:/127.0.0.1:8081] WRITE: 84B +-------------------------------------------------+ | 0 1 2 3 4 5 6 7 8 9 a b c d e f | +--------+-------------------------------------------------+----------------+ |00000000| 47 45 54 20 2f 20 48 54 54 50 2f 31 2e 31 0d 0a |GET / HTTP/1.1..| |00000010| 54 72 61 6e 73 66 65 72 2d 45 6e 63 6f 64 69 6e |Transfer-Encodin| |00000020| 67 3a 20 63 68 75 6e 6b 65 64 0d 0a 43 6f 6e 6e |g: chunked..Conn| |00000030| 65 63 74 69 6f 6e 3a 20 63 6c 6f 73 65 0d 0a 0d |ection: close...| |00000040| 0a 35 0d 0a 62 75 67 67 79 0d 0a 34 20 6e 6f 74 |.5..buggy..4 not| |00000050| 0d 0a 0d 0a |.... | +--------+-------------------------------------------------+----------------+ 2016-09-09 16:08:51,437 DEBUG [vert.x-eventloop-thread-2] LoggingHandler:71 - [id: 0xdaf6f8f4, L:/127.0.0.1:58962 - R:/127.0.0.1:8081] FLUSH 2016-09-09 16:08:51,456 TRACE [vert.x-eventloop-thread-1] HttpServerImpl:542 - Server received request: / 2016-09-09 16:08:51,467 TRACE [vert.x-eventloop-thread-1] RouterImpl:77 - Router: 712202734 accepting request GET http://127.0.0.1:8081/ 2016-09-09 16:08:51,469 TRACE [vert.x-eventloop-thread-1] RoutingContextImplBase:71 - Route matches: Route[ path:null pattern:null handler:io.vertx.ext.web.handler.impl.BodyHandlerImpl@54707f70 failureHandler:null order:0 methods:[]]@530304714 2016-09-09 16:08:51,469 TRACE [vert.x-eventloop-thread-1] RoutingContextImplBase:74 - Calling the handler 2016-09-09 16:08:56,434 DEBUG [vert.x-eventloop-thread-2] LoggingHandler:71 - [id: 0xdaf6f8f4, L:/127.0.0.1:58962 ! R:/127.0.0.1:8081] INACTIVE 2016-09-09 16:08:56,434 DEBUG [vert.x-eventloop-thread-2] LoggingHandler:71 - [id: 0xdaf6f8f4, L:/127.0.0.1:58962 ! R:/127.0.0.1:8081] UNREGISTERED Gradle Test Executor 1 finished executing tests.

io.vertx.test.ChunkedEncodingTest > missingNewLineAfterSize FAILED java.util.concurrent.TimeoutException at java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1771) at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1915) at io.vertx.test.ChunkedEncodingTest.missingNewLineAfterSize(ChunkedEncodingTest.java:95)

vietj commented 6 years ago

this is actually a Netty issue that tolerates some invalid chunk sizes (not all), it should generate instead a decoder result error

vietj commented 6 years ago

I've started a discussion in netty google group about it