You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by "coheigea (via GitHub)" <gi...@apache.org> on 2026/10/09 17:03:15 UTC

[PR] CXF-8922: Default form-data parts without Content-Type to text/plain [cxf]

coheigea opened a new pull request, #3563:
URL: https://github.com/apache/cxf/pull/3563

   Since 3.4.6 AttachmentDataSource reports "application/octet-stream" for
   parts with no Content-Type header, so the JAX-RS Attachment no longer
   falls back to text/plain. As a result simple form fields bound to
   non-String types (e.g. @Multipart Integer) found no MessageBodyReader
   and were silently injected as null.
   
   Per RFC 7578 section 4.4, a multipart/form-data part without a
   Content-Type defaults to text/plain. AttachmentUtil.createAttachment now
   applies that default to form-data parts that are not files (no
   "filename" parameter); other parts keep defaulting to
   application/octet-stream, and the "org.apache.cxf.attachment.content-type"
   property still overrides the default.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cxf.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CXF-8922: Default form-data parts without Content-Type to text/plain [cxf]

Posted by "coheigea (via GitHub)" <gi...@apache.org>.
coheigea merged PR #3563:
URL: https://github.com/apache/cxf/pull/3563


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cxf.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CXF-8922: Default form-data parts without Content-Type to text/plain [cxf]

Posted by "coheigea (via GitHub)" <gi...@apache.org>.
coheigea commented on code in PR #3563:
URL: https://github.com/apache/cxf/pull/3563#discussion_r4246123059


##########
core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java:
##########
@@ -412,14 +412,15 @@ public static Attachment createAttachment(InputStream stream, Map<String, List<S
 
         AttachmentImpl att = new AttachmentImpl(id);
 
+        String cd = getHeader(headers, "Content-Disposition");
+        String fileName = getContentDispositionFileName(cd);
+
         String ct = getHeader(headers, "Content-Type");
         if (StringUtils.isEmpty(ct)) {
-            ct = MessageUtils.getContextualString(message, ATTACHMENT_CONTENT_TYPE, "application/octet-stream");
+            ct = MessageUtils.getContextualString(message, ATTACHMENT_CONTENT_TYPE,
+                                                  getDefaultContentType(cd));

Review Comment:
   Good catch on the double parse. I’ll go with the second option and parse ContentDisposition once. Passing fileName directly wouldn’t work, because getContentDispositionFileName falls back to the name parameter, so a plain field like name="dzchunkindex" would look like a file and keep application/octet-stream. The new AttachmentUtilTest case covers that.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cxf.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CXF-8922: Default form-data parts without Content-Type to text/plain [cxf]

Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #3563:
URL: https://github.com/apache/cxf/pull/3563#discussion_r4235852213


##########
core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java:
##########
@@ -412,14 +412,15 @@ public static Attachment createAttachment(InputStream stream, Map<String, List<S
 
         AttachmentImpl att = new AttachmentImpl(id);
 
+        String cd = getHeader(headers, "Content-Disposition");
+        String fileName = getContentDispositionFileName(cd);
+
         String ct = getHeader(headers, "Content-Type");
         if (StringUtils.isEmpty(ct)) {
-            ct = MessageUtils.getContextualString(message, ATTACHMENT_CONTENT_TYPE, "application/octet-stream");
+            ct = MessageUtils.getContextualString(message, ATTACHMENT_CONTENT_TYPE,
+                                                  getDefaultContentType(cd));

Review Comment:
   We probably could pass `filename` to `getDefaultContentType` (since we already exacted it: 
   ```suggestion
   ct = MessageUtils.getContextualString(message, ATTACHMENT_CONTENT_TYPE,
                                                     getDefaultContentType(cd, filename));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cxf.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CXF-8922: Default form-data parts without Content-Type to text/plain [cxf]

Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #3563:
URL: https://github.com/apache/cxf/pull/3563#discussion_r4235852213


##########
core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java:
##########
@@ -412,14 +412,15 @@ public static Attachment createAttachment(InputStream stream, Map<String, List<S
 
         AttachmentImpl att = new AttachmentImpl(id);
 
+        String cd = getHeader(headers, "Content-Disposition");
+        String fileName = getContentDispositionFileName(cd);
+
         String ct = getHeader(headers, "Content-Type");
         if (StringUtils.isEmpty(ct)) {
-            ct = MessageUtils.getContextualString(message, ATTACHMENT_CONTENT_TYPE, "application/octet-stream");
+            ct = MessageUtils.getContextualString(message, ATTACHMENT_CONTENT_TYPE,
+                                                  getDefaultContentType(cd));

Review Comment:
   We probably could pass `filename` to `getDefaultContentType` (since we already exacted it:: 
   ```suggestion
   ct = MessageUtils.getContextualString(message, ATTACHMENT_CONTENT_TYPE,
                                                     getDefaultContentType(cd, filename));
   ```
   
   May be we could even push it to:
   ```
   ContentDisposition cd = getContentDisposition(headers, "Content-Disposition");
   
   ...
   ct = MessageUtils.getContextualString(message, ATTACHMENT_CONTENT_TYPE,
                                                     getDefaultContentType(cd));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cxf.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CXF-8922: Default form-data parts without Content-Type to text/plain [cxf]

Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #3563:
URL: https://github.com/apache/cxf/pull/3563#discussion_r4235852213


##########
core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java:
##########
@@ -412,14 +412,15 @@ public static Attachment createAttachment(InputStream stream, Map<String, List<S
 
         AttachmentImpl att = new AttachmentImpl(id);
 
+        String cd = getHeader(headers, "Content-Disposition");
+        String fileName = getContentDispositionFileName(cd);
+
         String ct = getHeader(headers, "Content-Type");
         if (StringUtils.isEmpty(ct)) {
-            ct = MessageUtils.getContextualString(message, ATTACHMENT_CONTENT_TYPE, "application/octet-stream");
+            ct = MessageUtils.getContextualString(message, ATTACHMENT_CONTENT_TYPE,
+                                                  getDefaultContentType(cd));

Review Comment:
   We probably could pass `filename` to `getDefaultContentType` (since we already exacted it:: 
   ```suggestion
   ct = MessageUtils.getContextualString(message, ATTACHMENT_CONTENT_TYPE,
                                                     getDefaultContentType(cd, filename));
   ```
   
   May be we could even push it to:
   ```
   ContentDisposition cd = getContentDisposition(headers, "Content-Disposition");
   
   ```
   ct = MessageUtils.getContextualString(message, ATTACHMENT_CONTENT_TYPE,
                                                     getDefaultContentType(cd));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cxf.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org