CXF 升级时删除的 MultipartBody Content-Type 属性

MultipartBody Content-Type attributes dropped on CXF Upgrade

将 Apache CXF 从 2.4.0 升级到 3.1.4 后,来自 JAX-RS 方法的响应的 Content-Type header 删除了几个属性。

在 CXF 2.4.0 下,header 是:

Content-Type: multipart/mixed; type="application/octet-stream"; boundary="uuid:61b631f1-0aa9-4cc8-ad85-3c09129ec442"; start="<DocumentName.ext>"; start-info="application/octet-stream"

在CXF 3.1.4下是:

Content-Type: multipart/mixed; boundary="uuid:804168d7-70ed-44e7-a471-9647372b9224"

注意:缺少属性 typestartstart-info

这是我们使用的代码:

@GET
@Path( "{order_id}/document/{document_id}/file" )
@Produces("multipart/mixed")
public MultipartBody getDocument( @PathParam( "order_id") int _orderId,  @PathParam( "document_id") int _documentId) throws Exception {

   FileInfo fileInfo = findFileInfo( _orderId, _documentId );

   List<Attachment> atts = new ArrayList<Attachment>();

   File internalFile = fileInfo.getActualFile();

   String fileName = fileInfo.getOriginalDocumentName();

   String fileSize = String.valueOf( internalFile.length() );

   ContentDisposition cd = new ContentDisposition("attachment; filename=\"" + fileName + "\"; size=" + fileSize );

   InputStream inputStreamToUse = new FileInputStream( internalFile );

   Attachment att = new Attachment(fileName, inputStreamToUse, cd);

   atts.add( att );

   return new MultipartBody(atts, true);    
}

我在 Migration Guides to changes in this area and the style of the above method seems to match the one from the getBooks2() method in the JAX-RS Multipart documentation 中找不到任何参考资料。

关于可能导致不同行为的原因的任何指导?

这样做是因为根据 https://www.rfc-editor.org/rfc/rfc2387.

显然只有 multipart/related 媒体类型可能具有可选的 startstart-info 属性

CXF 邮件列表上有更完整的主题讨论,特别是 this message,这表明 Content-Type 也被破坏了。