Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/using-tika/server/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ independent forked-process groups you run — see

|`maxRequestSizeBytes`
|`1 GiB`
|Maximum request body in bytes; larger requests are rejected with `413`. Enforced on bytes actually read, so a chunked upload with no `Content-Length` is bounded too. Bodies above xref:pipes/configuration.adoc#payload-limits[`maxInlineBytes`] are spooled to disk, so this also bounds how much one request can write. Raise it for larger documents, or set a negative value to disable the limit.
|Maximum request body in bytes; larger requests are rejected with `413`. Enforced on bytes actually read, so a chunked upload with no `Content-Length` is bounded too. Bodies above xref:pipes/configuration.adoc#payload-limits[`maxInlineBytes`] are spooled to disk, so this also bounds how much one request can write. Raise it for larger documents, or set a negative value to disable the limit. The server closes the connection while an oversized body is still arriving, so a client may see a connection reset instead of the `413`; Windows clients often do.

|`maxRequestReadMillis`
|`300000` (5 min)
Expand Down
2 changes: 1 addition & 1 deletion tika-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@
</contributors>

<properties>
<revision>4.2.1-SNAPSHOT</revision>
<revision>4.2.0-SNAPSHOT</revision>
<javaVersion>17</javaVersion>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.URI;
import java.net.http.HttpClient;
Expand All @@ -43,6 +44,7 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.zip.GZIPOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
Expand Down Expand Up @@ -164,7 +166,8 @@ public void testEveryEndpointAnswersOverLimitChunkedBeforeBodyEnds() throws Exce
if (status.startsWith("2")) {
failures.add(String.join(" ", endpoint) + " " + e.getKey() + " -> " + status);
}
anyTooLarge |= "413".equals(status);
// a reset may drop the 413 (Windows); it too proves the server stopped reading
anyTooLarge |= "413".equals(status) || "reset".equals(status);
}
if (!anyTooLarge) {
failures.add(String.join(" ", endpoint) + " never reached the limit: " + statuses);
Expand Down Expand Up @@ -560,14 +563,18 @@ private static String fillTemplate(String path) {
return sb.toString();
}

/** Status code, "closed" if the connection closed first, or null if nothing came in time. */
/**
* Status code, "closed" if the connection closed first, "reset" if it was reset before the
* whole body was sent, or null if nothing came in time or only after the whole body was read.
*/
private String sendChunked(String[] endpoint, String contentType, byte[] preamble)
throws IOException {
throws IOException, InterruptedException {
byte[] filler = new byte[64 * 1024];
Arrays.fill(filler, (byte) 'a');
try (Socket socket = new Socket("localhost", integrationTestPort)) {
socket.setSoTimeout(10_000);
OutputStream out = socket.getOutputStream();
AtomicBoolean sentAll = new AtomicBoolean();
Thread writer = new Thread(() -> {
try {
out.write(requestHead(endpoint, contentType)
Expand All @@ -577,14 +584,20 @@ private String sendChunked(String[] endpoint, String contentType, byte[] preambl
writeChunk(out, filler);
}
out.flush();
sentAll.set(true);
// the terminating chunk is never sent
} catch (IOException e) {
// the server stopped reading and closed
}
});
writer.setDaemon(true);
writer.start();
return readStatus(socket);
try {
return readStatus(socket);
} catch (SocketException e) {
writer.join(10_000);
return sentAll.get() ? null : "reset";
}
}
}

Expand Down
Loading