Alright, I tried this:
System.out.println("start");
PooledByteBuffer poolBuffer = exchange.getConnection().getByteBufferPool().getArrayBackedPool().allocate();
byte[] buffer = poolBuffer.getBuffer().array(); //
buffer
.length is 16KB
.exchange.startBlocking();
OutputStream output = exchange.getOutputStream();
try (var input = new FileInputStream(file)) {
while (true) {
int count = input.read(buffer);
if (count == -1) break;
output.flush();
// Before write() to avoid flushing a closed OutputStream. output.write(buffer, 0, count);
}
}
exchange.endExchange();
System.out.println("end");
When I hit the URL, I see "start" and "end" printed immediately in the server log even though the
curl
download takes much, much longer at 10 bytes/sec.
That was on Debian. Next I tried the same on Windows 10 and there I see only "start" while the download is in progress. That is true even if I remove the flush.