You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we send an http request beginning with "P" (i.e. a POST, PATCH or PUT) split across two packets where the first packet has data length of 1 byte and the second packet contains the rest of the request, then the Http1xOrHttp2Handler reads the 1 byte packet, and then throws it away.
When the second packet comes in it does not aggregate the 1 byte that it previously read with the second packet, resulting in the method being received as "OST", "ATCH", or "UT".
A workaround is to disable the Http1xOrHttp2Handler with: System.setProperty("vertx.disableH2c", "true");
Reproducer:
@Test
public void test1BytePost() throws Exception {
// The test will pass if we disable the http2 decoder:
// System.setProperty("vertx.disableH2c", "true");
CountDownLatch latch1 = new CountDownLatch(1);
server.requestHandler(req -> {
assertEquals("POST", req.rawMethod());
latch1.countDown();
});
String fullRequest = "POST /whatever HTTP/1.1\r\n\r\n";
CountDownLatch latch2 = new CountDownLatch(1);
server.listen(onSuccess(s -> {
latch2.countDown();
}));
latch2.await();
try (Socket sock = new Socket("localhost", 8080)) {
byte[] rawData = fullRequest.getBytes();
System.out.println("total Len = " + rawData.length);
// send 1 byte packet
sock.getOutputStream().write(rawData, 0, 1);
sock.getOutputStream().flush();
Thread.sleep(750);
// send the rest
sock.getOutputStream().write(rawData, 1, rawData.length - 1);
sock.getOutputStream().flush();
}
latch1.await();
}
The text was updated successfully, but these errors were encountered:
purplefox
changed the title
Bug in Http1xOrHttp2Handler for 1 byte packet
Packet lost in Http1xOrHttp2Handler
Jun 2, 2017
If we send an http request beginning with "P" (i.e. a POST, PATCH or PUT) split across two packets where the first packet has data length of 1 byte and the second packet contains the rest of the request, then the Http1xOrHttp2Handler reads the 1 byte packet, and then throws it away.
When the second packet comes in it does not aggregate the 1 byte that it previously read with the second packet, resulting in the method being received as "OST", "ATCH", or "UT".
A workaround is to disable the Http1xOrHttp2Handler with:
System.setProperty("vertx.disableH2c", "true");
Reproducer:
The text was updated successfully, but these errors were encountered: