Skip to content

Commit

Permalink
Add ContentDisposition header to WSS responses (frankframework#5314)
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsm5 authored Sep 5, 2023
1 parent 6382219 commit c653455
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,24 +209,25 @@ public SOAPMessage invoke(SOAPMessage request) {
for (final Node part : parts) {
Element partElement = (Element) part;

if (StringUtils.isNotEmpty(partElement.getAttribute("name"))) {
log.info("multipart xml attribute name is no longer used!");
}

String partSessionKey = partElement.getAttribute("sessionKey");
String name = partElement.getAttribute("name");
Message partObject = pipelineSession.getMessage(partSessionKey);

if (!partObject.isNull()) {
String mimeType = partElement.getAttribute("mimeType");
String mimeType = partElement.getAttribute("mimeType"); //Optional, auto detected if not set
partObject.unscheduleFromCloseOnExitOf(pipelineSession); // Closed by the SourceClosingDataHandler
SourceClosingDataHandler dataHander = new SourceClosingDataHandler(new MessageDataSource(partObject, mimeType));
MessageDataSource ds = new MessageDataSource(partObject, mimeType);
SourceClosingDataHandler dataHander = new SourceClosingDataHandler(ds);
AttachmentPart attachmentPart = soapMessage.createAttachmentPart(dataHander);
attachmentPart.setContentId(partSessionKey); // ContentID is URLDecoded, it may not contain special characters, see #4661

String filename = StringUtils.isNotBlank(name) ? name : ds.getName();
attachmentPart.addMimeHeader("Content-Disposition", "attachment; name=\""+filename+"\"; filename=\""+filename+"\"");
soapMessage.addAttachmentPart(attachmentPart);

log.debug(getLogPrefix(messageId) + "appended filepart [" + partSessionKey + "] key [" + partSessionKey + "]");
log.debug("appended filepart [{}] key [{}]", filename, partSessionKey);
} else {
log.debug(getLogPrefix(messageId) + "skipping filepart [" + partSessionKey + "] key [" + partSessionKey + "], content is <NULL>");
log.debug("skipping filepart [{}] key [{}], content is <NULL>", name, partSessionKey);
}
}
}
Expand Down

0 comments on commit c653455

Please sign in to comment.