Example usage for org.apache.http.entity.mime Header removeFields

List of usage examples for org.apache.http.entity.mime Header removeFields

Introduction

In this page you can find the example usage for org.apache.http.entity.mime Header removeFields.

Prototype

public int removeFields(final String name) 

Source Link

Usage

From source file:nl.nn.adapterframework.http.mime.MultipartEntityBuilder.java

public MultipartEntityBuilder addPart(FormBodyPart bodyPart) {
    if (bodyPart == null) {
        return this;
    }/*from  w  ww.  j  av  a  2s .c  o m*/
    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;
}