Fixes flaky FCGI test HttpClientTest.testPOSTWithContentTracksProgress().

The content must be consumed by the server, otherwise:
* the server Handler exits
* the implementation tries to consume the content on its way to complete
* the request content cannot be consumed, so the connection is closed
* the server closing the connection causes an EOFException on the client

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2022-12-07 16:20:22 +01:00
parent 3d3c95462a
commit 2538a91201
No known key found for this signature in database
GPG Key ID: 1677D141BCF3584D
1 changed files with 10 additions and 1 deletions

View File

@ -14,6 +14,7 @@
package org.eclipse.jetty.fcgi.server;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.ByteBuffer;
@ -351,7 +352,15 @@ public class HttpClientTest extends AbstractHttpClientServerTest
@Test
public void testPOSTWithContentTracksProgress() throws Exception
{
start(new EmptyServerHandler());
start(new AbstractHandler()
{
@Override
public void handle(String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
baseRequest.setHandled(true);
IO.copy(baseRequest.getInputStream(), OutputStream.nullOutputStream());
}
});
AtomicInteger progress = new AtomicInteger();
ContentResponse response = client.POST(scheme + "://localhost:" + connector.getLocalPort())