You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by "Alexandre Garnier (JIRA)" <ji...@apache.org> on 2014/11/10 16:27:34 UTC

[jira] [Comment Edited] (GERONIMO-6480) Wrong attachment 'Content-type' in some conditions

    [ https://issues.apache.org/jira/browse/GERONIMO-6480?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14204884#comment-14204884 ] 

Alexandre Garnier edited comment on GERONIMO-6480 at 11/10/14 3:26 PM:
-----------------------------------------------------------------------

Here is a test-case showing the content-type at client side.
You can switch the javamail implementation between geronimo javamail and Oracle/Sun javamail by changing the dependencies in the {{pom.xml}}.

BTW, calling {{getContentType()}} will always at least return {{text/plain}} because it's the default value, but when the real value is {{null}}, then it's correctly set afterwards (if not forced to 'text/plain' when adding the 'name=' part)


was (Author: zigarn0):
Here is a test-case showing the content-type at client side.
You can switch the javamail implementation between geronimo javamail and Oracle/Sun javamail.

BTW, calling {{getContentType()}} will always at least return {{text/plain}} because it's the default value, but when the real value is {{null}}, then it's correctly set afterwards (if not forced to 'text/plain' when adding the 'name=' part)

> Wrong attachment 'Content-type' in some conditions
> --------------------------------------------------
>
>                 Key: GERONIMO-6480
>                 URL: https://issues.apache.org/jira/browse/GERONIMO-6480
>             Project: Geronimo
>          Issue Type: Bug
>      Security Level: public(Regular issues) 
>          Components: mail
>            Reporter: Alexandre Garnier
>            Assignee: Hendrik Saly
>         Attachments: GERONIMO-6480.tar.gz
>
>
> When you set an attachment filename before having a Content-type defined, then the Content-type is set to 'text/plain'.
> {code:language=java}
> BodyPart attachmentPart = new MimeBodyPart();
> attachmentPart.setDataHandler(dh);
> attachmentPart.setFileName("test.pdf");
> {code}
> ==> Content-type = 'text/plain'
> {code:language=java}
> BodyPart attachmentPart = new MimeBodyPart();
> attachmentPart.addHeader("Content-Type", "aplication/pdf");
> attachmentPart.setDataHandler(dh);
> attachmentPart.setFileName("test.pdf");
> {code}
> ==> Content-type = 'text/plain' (because setDataHandler reset Headers)
> {code:language=java}
> BodyPart attachmentPart = new MimeBodyPart();
> attachmentPart.setDataHandler(dh);
> attachmentPart.addHeader("Content-Type", "aplication/pdf");
> attachmentPart.setFileName("test.pdf");
> {code}
> ==> Right Content-Type
> {code:language=java}
> System.setProperty("mail.mime.setcontenttypefilename", Boolean.FALSE.toString());
> BodyPart attachmentPart = new MimeBodyPart();
> attachmentPart.setDataHandler(dh);
> attachmentPart.setFileName("test.pdf");
> {code}
> ==> Right Content-Type
> {code:language=java}
> BodyPart attachmentPart = new MimeBodyPart();
> attachmentPart.setFileName("test.pdf");
> attachmentPart.setDataHandler(dh);
> {code}
> ==> Right Content-Type
> It's because of solution of GERONIMO-2091 (SVN rev412720).
> The right solution is in [javamail MimeBodyPart.java|https://java.net/projects/javamail/sources/mercurial/content/mail/src/main/java/javax/mail/internet/MimeBodyPart.java?rev=569] : use direct access to Header (instead of method with default value) and do nothing if not yet defined. This solution could allow to remove the {{MIME_SETCONTENTTYPEFILENAME}} property.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)