Skip to content

Commit

Permalink
Removed charset from main content-type; #263
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Aug 19, 2024
1 parent fcc4c3c commit 7b60ccc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ public final class MimeMessageCreator
final MailcapCommandMap aCommandMap = (MailcapCommandMap) CommandMap.getDefaultCommandMap ();
for (final String sMimeType : aCommandMap.getMimeTypes ())
for (final CommandInfo aCI : aCommandMap.getAllCommands (sMimeType))
aSB.append (sMimeType).append ("; ").append (aCI.getCommandName ()).append ("; ").append (aCI.getCommandClass ()).append ('\n');
aSB.append (sMimeType)
.append ("; ")
.append (aCI.getCommandName ())
.append ("; ")
.append (aCI.getCommandClass ())
.append ('\n');
LoggerFactory.getLogger ("root").info (aSB.toString ());
}

Expand All @@ -97,14 +102,15 @@ public static AS4MimeMessage generateMimeMessage (@Nonnull final ESoapVersion eS
ValueEnforcer.notNull (aSoapEnvelope, "SoapEnvelope");

final Charset aCharset = AS4XMLHelper.XWS.getCharset ();
final SoapMimeMultipart aMimeMultipart = new SoapMimeMultipart (eSoapVersion, aCharset);
final SoapMimeMultipart aMimeMultipart = new SoapMimeMultipart (eSoapVersion);
final EContentTransferEncoding eCTE = EContentTransferEncoding.BINARY;
final String sContentType = eSoapVersion.getMimeType (aCharset).getAsString ();
final String sRootContentType = eSoapVersion.getMimeType (aCharset).getAsString ();

{
// Message Itself (repeatable)
final MimeBodyPart aMessagePart = new MimeBodyPart ();
aMessagePart.setDataHandler (new DataHandler (new DOMSource (aSoapEnvelope), sContentType));
aMessagePart.setDataHandler (new DataHandler (new DOMSource (aSoapEnvelope), sRootContentType));
// Set AFTER DataHandler
aMessagePart.setHeader (CHttpHeader.CONTENT_TRANSFER_ENCODING, eCTE.getID ());
aMimeMultipart.addBodyPart (aMessagePart);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
*/
package com.helger.phase4.messaging.mime;

import java.nio.charset.Charset;

import javax.annotation.Nonnull;

import com.helger.phase4.soap.ESoapVersion;
Expand All @@ -34,16 +32,18 @@
*/
public class SoapMimeMultipart extends MimeMultipart
{
public SoapMimeMultipart (@Nonnull final ESoapVersion eSoapVersion,
@Nonnull final Charset aCharset) throws ParseException
private static final String RELATED = "related";
private static final String CT_PARAM_TYPE = "type";

public SoapMimeMultipart (@Nonnull final ESoapVersion eSoapVersion) throws ParseException
{
super ("related");
super (RELATED);

// type parameter is essential for Axis to work!
// But no charset! RFC 2387, section 3.4 has a special definition
final ContentType aContentType = new ContentType (contentType);
aContentType.setParameter ("type", eSoapVersion.getMimeType ().getAsString ());
aContentType.setParameter ("charset", aCharset.name ());
aContentType.setParameter (CT_PARAM_TYPE, eSoapVersion.getMimeType ().getAsString ());
// No "charset" parameter here (see #263)
contentType = aContentType.toString ();
}
}

0 comments on commit 7b60ccc

Please sign in to comment.