HTTPCLIENT-874: Override method MultipartEntity.addPart so that applications may use FormBodyPart

Contributed by Gerald Turner <gturner at unzane.com>

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@811556 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2009-09-04 21:22:17 +00:00
parent fdfded17c2
commit d2b10048b9
1 changed files with 11 additions and 3 deletions

View File

@ -43,6 +43,7 @@ import org.apache.http.entity.mime.content.ContentBody;
import org.apache.http.message.BasicHeader; import org.apache.http.message.BasicHeader;
import org.apache.http.protocol.HTTP; import org.apache.http.protocol.HTTP;
import org.apache.james.mime4j.field.Fields; import org.apache.james.mime4j.field.Fields;
import org.apache.james.mime4j.message.BodyPart;
import org.apache.james.mime4j.message.Message; import org.apache.james.mime4j.message.Message;
/** /**
@ -121,11 +122,18 @@ public class MultipartEntity implements HttpEntity {
return buffer.toString(); return buffer.toString();
} }
public void addPart(final String name, final ContentBody contentBody) { /**
this.multipart.addBodyPart(new FormBodyPart(name, contentBody)); * @since 4.1
*/
public void addPart(final BodyPart bodyPart) {
this.multipart.addBodyPart(bodyPart);
this.dirty = true; this.dirty = true;
} }
public void addPart(final String name, final ContentBody contentBody) {
addPart(new FormBodyPart(name, contentBody));
}
public boolean isRepeatable() { public boolean isRepeatable() {
List<?> parts = this.multipart.getBodyParts(); List<?> parts = this.multipart.getBodyParts();
for (Iterator<?> it = parts.iterator(); it.hasNext(); ) { for (Iterator<?> it = parts.iterator(); it.hasNext(); ) {