You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Michael Vorburger (JIRA)" <ji...@apache.org> on 2007/11/07 02:09:50 UTC
[jira] Issue Comment Edited: (HTTPCLIENT-317) HTTP Client doesn't
support multipart/related content-type
[ https://issues.apache.org/jira/browse/HTTPCLIENT-317?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12540630 ]
vorburger edited comment on HTTPCLIENT-317 at 11/6/07 5:08 PM:
-----------------------------------------------------------------------
This followowing two classes I just wrote do the trick for me reg. the 2 problems above... not sure this is fully sufficient? Might help somebody else. Regards, Michael Vorburger.
class MultipartRelatedRequestEntity extends MultipartRequestEntity {
public MultipartRelatedRequestEntity(Part[] parts, HttpMethodParams params) {
super(parts, params);
}
public String getContentType()
{
String header = super.getContentType();
int ix = header.indexOf( "boundary" );
String mimeType = "application/soap+xml"; // or "text/xml\", or doesn't actually matter?
return "multipart/related; type=\"" + mimeType + "\"; start=\"" + ROOTPART_NAME + "\"; " + header.substring( ix );
}
}
private static class MultipartRelatedStringPart extends StringPart {
protected static final String CONTENT_ID = "Content-ID: <";
protected static final byte[] CONTENT_ID_BYTES = EncodingUtil.getAsciiBytes(CONTENT_ID);
protected static final String GT = ">";
protected static final byte[] GT_BYTES = EncodingUtil.getAsciiBytes(GT);
public MultipartRelatedStringPart(String name, String value) {
super(name, value);
}
public MultipartRelatedStringPart(String name, String value, String charset) {
super(name, value, charset);
}
protected void sendDispositionHeader(OutputStream out) throws IOException {
out.write(CONTENT_ID_BYTES);
out.write(EncodingUtil.getAsciiBytes(getName()));
out.write(GT_BYTES);
}
}
was (Author: vorburger):
This does the trick for me reg. problem 2 above... not sure this is fully sufficient? Might help somebody else. Regards, Michael Vorburger.
class MultipartRelatedRequestEntity extends MultipartRequestEntity {
public MultipartRelatedRequestEntity(Part[] parts, HttpMethodParams params) {
super(parts, params);
}
public String getContentType()
{
String header = super.getContentType();
int ix = header.indexOf( "boundary" );
String mimeType = "application/soap+xml"; // or "text/xml\", or doesn't actually matter?
return "multipart/related; type=\"" + mimeType + "\"; start=\"" + ROOTPART_NAME + "\"; " + header.substring( ix );
}
}
> HTTP Client doesn't support multipart/related content-type
> ----------------------------------------------------------
>
> Key: HTTPCLIENT-317
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-317
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Components: HttpClient
> Affects Versions: 2.0 Final
> Environment: Operating System: Windows XP
> Platform: PC
> Reporter: peter
> Priority: Minor
> Fix For: 4.0 Final
>
>
> It is not possible to sent data easely as a multipart/related content-type (as
> discribed in rfc 2387) using Http Client.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org