Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

Fix the race in the MCP oversized-body 413 test (#8799)

Reece Browne89441f07e6d2
diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/mcp/security/McpOAuthIntegrationTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/mcp/security/McpOAuthIntegrationTest.java
index 8b57a60c56..a4610405ed 100644
--- a/app/proprietary/src/test/java/stirling/software/proprietary/mcp/security/McpOAuthIntegrationTest.java
+++ b/app/proprietary/src/test/java/stirling/software/proprietary/mcp/security/McpOAuthIntegrationTest.java
@@ -188,7 +188,18 @@ class McpOAuthIntegrationTest {
new StringBuilder("{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"x\",\"params\":\"");
big.append("A".repeat(300 * 1024));
big.append("\"}");
- HttpResponse<String> response = postMcp(token, big.toString());
+ // Expect: 100-continue holds the body back until the server answers the headers. The filter
+ // rejects on Content-Length alone and closes the connection, so a client already streaming
+ // the body would hit a broken pipe instead of reading the 413.
+ HttpRequest request =
+ HttpRequest.newBuilder()
+ .uri(URI.create(base() + "/mcp"))
+ .header("Content-Type", "application/json")
+ .header("Authorization", "Bearer " + token)
+ .expectContinue(true)
+ .POST(HttpRequest.BodyPublishers.ofString(big.toString()))
+ .build();
+ HttpResponse<String> response = http.send(request, HttpResponse.BodyHandlers.ofString());
assertThat(response.statusCode()).isEqualTo(413);
}