Java 类org.apache.http.entity.mime.Header 实例源码

项目:iaf    文件:MultipartForm.java   
/**
  * Write the multipart header fields; depends on the style.
  */
protected void formatMultipartHeader(
        final FormBodyPart part,
        final OutputStream out) throws IOException {

        // For strict, we output all fields with MIME-standard encoding.
        final Header header = part.getHeader();
        for (final MinimalField field: header) {
            writeField(field, out);
        }
    }
项目:iaf    文件:MultipartEntityBuilder.java   
public MultipartEntityBuilder addPart(FormBodyPart bodyPart) {
    if (bodyPart == null) {
        return this;
    }
    if (this.bodyParts == null) {
        this.bodyParts = new ArrayList<FormBodyPart>();
    }

    if(mtom) {
        Header header = bodyPart.getHeader();
        String contentID;
        String fileName = bodyPart.getBody().getFilename();
        header.removeFields("Content-Disposition");
        if(fileName == null) {
            contentID = "<"+bodyPart.getName()+">";
        }
        else {
            bodyPart.addField("Content-Disposition", "attachment; name=\""+fileName+"\"; filename=\""+fileName+"\"");
            contentID = "<"+fileName+">";
        }
        bodyPart.addField("Content-ID", contentID);

        if(firstPart == null)
            firstPart = contentID;
    }

    this.bodyParts.add(bodyPart);
    return this;
}