This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/main by this push:
     new 17d67e790c CXF-9138: Content-Transfer-Encoding header deprecated for 
multipart/form-data parts (#2846)
17d67e790c is described below

commit 17d67e790c59c9f8afc364267657b39ad1e915b3
Author: Andriy Redko <[email protected]>
AuthorDate: Sun Feb 1 09:21:34 2026 -0500

    CXF-9138: Content-Transfer-Encoding header deprecated for 
multipart/form-data parts (#2846)
---
 .../java/org/apache/cxf/attachment/AttachmentSerializer.java   | 10 +++++++++-
 .../cxf/systest/jaxrs/multipart/MultipartSupportTest.java      |  6 +++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git 
a/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java 
b/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
index 9b6922c347..d32c5a33a5 100644
--- a/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
+++ b/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
@@ -43,6 +43,8 @@ import org.apache.cxf.message.Message;
 public class AttachmentSerializer {
     // http://tools.ietf.org/html/rfc2387
     private static final String DEFAULT_MULTIPART_TYPE = "multipart/related";
+    // https://www.rfc-editor.org/rfc/rfc7578
+    private static final String MULTIPART_FORM_DATA_TYPE = 
"multipart/form-data";
 
     private String contentTransferEncoding = AttachmentUtil.BINARY;
 
@@ -208,7 +210,13 @@ public class AttachmentSerializer {
                                      Map<String, List<String>> headers, Writer 
writer) throws IOException {
         writer.write("\r\nContent-Type: ");
         writer.write(contentType);
-        writer.write("\r\nContent-Transfer-Encoding: " + 
contentTransferEncoding + "\r\n");
+
+        // Content-Transfer-Encoding is deprecated (see please 
https://www.rfc-editor.org/rfc/rfc7578#page-6)
+        if (!MULTIPART_FORM_DATA_TYPE.equalsIgnoreCase(multipartType)) {
+            writer.write("\r\nContent-Transfer-Encoding: " + 
contentTransferEncoding + "\r\n");
+        } else {
+            writer.write("\r\n");
+        }
 
         if (attachmentId != null) {
             attachmentId = checkAngleBrackets(attachmentId);
diff --git 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/multipart/MultipartSupportTest.java
 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/multipart/MultipartSupportTest.java
index 0a6ab0ebea..dfb7d3ac8d 100644
--- 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/multipart/MultipartSupportTest.java
+++ 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/multipart/MultipartSupportTest.java
@@ -143,9 +143,9 @@ public class MultipartSupportTest extends 
AbstractBusClientServerTestBase {
                 Assert.assertNotNull(part);
                 Assert.assertEquals("Add part on return.", 
part.getContent(String.class));
 
-                // Check headers.  Should be 5:  Content-Disposition, 
Transfer-Encoding, 
-                // Content-Type, and the 2 headers that were added.
-                if ((part.getHeaders() == null) || (part.getHeaders().size() 
!= 5)) {
+                // Check headers.  Should be 5:  Content-Disposition, 
Content-Type,
+                // and the 2 headers that were added.
+                if ((part.getHeaders() == null) || (part.getHeaders().size() 
!= 4)) {
                     Assert.fail("Expected 4 headers, received " + 
part.getHeaders().size());
                 }
 

Reply via email to