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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to