}
return encoding;
}
static void updateHeaders(MimePart part) throws MessagingException {
DataHandler dh = part.getDataHandler();
if (dh == null) // Huh ?
return;
try {
String type = dh.getContentType();
boolean composite = false;
boolean needCTHeader = part.getHeader("Content-Type") == null;
ContentType cType = new ContentType(type);
/*
* If this is a multipart, give sub-parts a chance to
* update their headers. Even though the data for this
* multipart may have come from a stream, one of the
* sub-parts may have been updated.
*/
if (cType.match("multipart/*")) {
// If multipart, recurse
composite = true;
Object o;
if (part instanceof MimeBodyPart) {
MimeBodyPart mbp = (MimeBodyPart)part;
o = mbp.cachedContent != null ?
mbp.cachedContent : dh.getContent();
} else if (part instanceof MimeMessage) {
MimeMessage msg = (MimeMessage)part;
o = msg.cachedContent != null ?
msg.cachedContent : dh.getContent();
} else
o = dh.getContent();
if (o instanceof MimeMultipart)
((MimeMultipart)o).updateHeaders();
else
throw new MessagingException("MIME part of type \"" +
type + "\" contains object of type " +