This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/dev/pr-11281-7604a83ec802a0b148e98e557fb9184c48127988 in repository https://gitbox.apache.org/repos/asf/seatunnel.git
commit 0cf767d0c891a95580ce47e9c423e3d065ef3e41 Author: xuepeng <[email protected]> AuthorDate: Sun Oct 25 13:44:29 2026 +0000 [Fix][Connector-V2] Remove incorrect HTTP entity content encoding (#11281) Co-authored-by: DanielLeens <[email protected]> Co-authored-by: David Zollo <[email protected]> --- .../http/client/HttpClientProviderTest.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/seatunnel-connectors-v2/connector-http/connector-http-base/src/test/java/org/apache/seatunnel/connectors/seatunnel/http/client/HttpClientProviderTest.java b/seatunnel-connectors-v2/connector-http/connector-http-base/src/test/java/org/apache/seatunnel/connectors/seatunnel/http/client/HttpClientProviderTest.java index 429c884927..d948454a2d 100644 --- a/seatunnel-connectors-v2/connector-http/connector-http-base/src/test/java/org/apache/seatunnel/connectors/seatunnel/http/client/HttpClientProviderTest.java +++ b/seatunnel-connectors-v2/connector-http/connector-http-base/src/test/java/org/apache/seatunnel/connectors/seatunnel/http/client/HttpClientProviderTest.java @@ -112,10 +112,26 @@ class HttpClientProviderTest { Assertions.assertNull(post.getEntity().getContentEncoding()); } + @Test + void testJsonMapBodyDoesNotSetContentEncodingHeader() throws Exception { + HttpPost post = new HttpPost("http://localhost:8080"); + Map<String, Object> body = new HashMap<>(); + body.put("key", "value"); + + HttpClientProvider.addBody(post, body); + + Assertions.assertEquals("application/json", post.getFirstHeader("Content-Type").getValue()); + Assertions.assertNull(post.getFirstHeader("Content-Encoding")); + Assertions.assertNull(post.getEntity().getContentEncoding()); + Assertions.assertTrue( + post.getEntity().getContentType().getValue().contains("application/json")); + } + @Test void executePreservesNestedJsonBody() throws Exception { AtomicReference<String> receivedBody = new AtomicReference<>(); AtomicReference<String> receivedQuery = new AtomicReference<>(); + AtomicReference<String> receivedContentEncoding = new AtomicReference<>(); List<String> receivedContentTypes = Collections.synchronizedList(new ArrayList<>()); server = HttpServer.create(new InetSocketAddress("127.0.0.1", 0), 0); server.createContext( @@ -123,6 +139,8 @@ class HttpClientProviderTest { exchange -> { receivedBody.set(readRequestBody(exchange.getRequestBody())); receivedQuery.set(exchange.getRequestURI().getQuery()); + receivedContentEncoding.set( + exchange.getRequestHeaders().getFirst("Content-Encoding")); receivedContentTypes.clear(); receivedContentTypes.addAll(exchange.getRequestHeaders().get("Content-Type")); exchange.sendResponseHeaders(200, -1); @@ -148,6 +166,8 @@ class HttpClientProviderTest { Assertions.assertEquals(200, response.getCode()); Assertions.assertEquals(body, receivedBody.get()); Assertions.assertEquals("traceId=123", receivedQuery.get()); + Assertions.assertNull( + receivedContentEncoding.get(), "JSON is a content type, not a content encoding"); // The caller-supplied Content-Type must not be duplicated. Otherwise the request // would carry two Content-Type headers, which RFC 7230 ยง3.2.2 forbids for // non-list headers and yields implementation-defined behaviour on the receiver.
