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
This commit is contained in:
Oleg Kalnichevski 2014-06-03 14:11:22 +00:00
parent 700b390d8e
commit 8e30f60efe
1 changed files with 12 additions and 2 deletions

View File

@ -94,6 +94,15 @@ public class MultipartEntityBuilder {
return this; 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) { public MultipartEntityBuilder setCharset(final Charset charset) {
this.charset = charset; this.charset = charset;
return this; return this;
@ -161,9 +170,10 @@ public class MultipartEntityBuilder {
private String generateContentType( private String generateContentType(
final String boundary, final String boundary,
final String subType,
final Charset charset) { final Charset charset) {
final StringBuilder buffer = new StringBuilder(); final StringBuilder buffer = new StringBuilder();
buffer.append("multipart/form-data; boundary="); buffer.append("multipart/").append(subType).append("; boundary=");
buffer.append(boundary); buffer.append(boundary);
if (charset != null) { if (charset != null) {
buffer.append("; charset="); buffer.append("; charset=");
@ -200,7 +210,7 @@ public class MultipartEntityBuilder {
default: default:
form = new HttpStrictMultipart(st, cs, b, bps); 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() { public HttpEntity build() {