From 8e30f60efe0490bfab4e1e7bdff15cd97e12be27 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Tue, 3 Jun 2014 14:11:22 +0000 Subject: [PATCH] HTTPCLIENT-1503: setter for custom multipart subtypes git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1599553 13f79535-47bb-0310-9956-ffa450edef68 --- .../http/entity/mime/MultipartEntityBuilder.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntityBuilder.java b/httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntityBuilder.java index 7b3a181a7..859cf1ed3 100644 --- a/httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntityBuilder.java +++ b/httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntityBuilder.java @@ -94,6 +94,15 @@ public class MultipartEntityBuilder { return this; } + /** + * @since 4.4 + */ + public MultipartEntityBuilder setMimeSubtype(final String subType) { + Args.notBlank(subType, "MIME subtype"); + this.subType = subType; + return this; + } + public MultipartEntityBuilder setCharset(final Charset charset) { this.charset = charset; return this; @@ -161,9 +170,10 @@ public class MultipartEntityBuilder { private String generateContentType( final String boundary, + final String subType, final Charset charset) { final StringBuilder buffer = new StringBuilder(); - buffer.append("multipart/form-data; boundary="); + buffer.append("multipart/").append(subType).append("; boundary="); buffer.append(boundary); if (charset != null) { buffer.append("; charset="); @@ -200,7 +210,7 @@ public class MultipartEntityBuilder { default: form = new HttpStrictMultipart(st, cs, b, bps); } - return new MultipartFormEntity(form, generateContentType(b, cs), form.getTotalLength()); + return new MultipartFormEntity(form, generateContentType(b, st, cs), form.getTotalLength()); } public HttpEntity build() {