Issue #5605 - java.io.IOException: unconsumed input during http request parsing.
Writing content in separate writes may result in the server only reading partial content, producing a response with `Connection: close` that would cause the client socket to stop receiving data for the next response, failing the test. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
f533380fe8
commit
e3e5c2e25a
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -147,8 +148,7 @@ public class GracefulStopTest
|
|||
handler.latch = new CountDownLatch(1);
|
||||
final int port = connector.getLocalPort();
|
||||
Socket client = new Socket("127.0.0.1", port);
|
||||
client.getOutputStream().write(post);
|
||||
client.getOutputStream().write(BODY_67890);
|
||||
client.getOutputStream().write(concat(post, BODY_67890));
|
||||
client.getOutputStream().flush();
|
||||
assertTrue(handler.latch.await(5, TimeUnit.SECONDS));
|
||||
|
||||
|
@ -163,8 +163,7 @@ public class GracefulStopTest
|
|||
void assertAvailable(Socket client, byte[] post, TestHandler handler) throws Exception
|
||||
{
|
||||
handler.latch = new CountDownLatch(1);
|
||||
client.getOutputStream().write(post);
|
||||
client.getOutputStream().write(BODY_67890);
|
||||
client.getOutputStream().write(concat(post, BODY_67890));
|
||||
client.getOutputStream().flush();
|
||||
assertTrue(handler.latch.await(5, TimeUnit.SECONDS));
|
||||
|
||||
|
@ -188,8 +187,7 @@ public class GracefulStopTest
|
|||
Thread.sleep(100);
|
||||
}
|
||||
|
||||
client.getOutputStream().write(post);
|
||||
client.getOutputStream().write(BODY_67890);
|
||||
client.getOutputStream().write(concat(post, BODY_67890));
|
||||
client.getOutputStream().flush();
|
||||
HttpTester.Response response = HttpTester.parseResponse(client.getInputStream());
|
||||
|
||||
|
@ -281,6 +279,13 @@ public class GracefulStopTest
|
|||
}).start();
|
||||
}
|
||||
|
||||
private byte[] concat(byte[] bytes1, byte[] bytes2)
|
||||
{
|
||||
byte[] bytes = Arrays.copyOf(bytes1, bytes1.length + bytes2.length);
|
||||
System.arraycopy(bytes2, 0, bytes, bytes1.length, bytes2.length);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotGraceful() throws Exception
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue