hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: HttpEntity and MimeMessage
Date Sun, 22 Jan 2012 20:54:59 GMT
On Sun, 2012-01-22 at 00:08 -0600, Manjiri Karmarkar wrote:
> Hello,
> 
> I am trying to create a "HttpEntity" from a MimeMessage
> (javax.mail.internet.MimeMessage).
> I was wondering if there is special implementation for the MimeMessage ?
> 
> The following code isnt working well for me because
> mimeMessage.getInputStream only gives me the message body (and not the
> headers ... i want to convert entire MimeMessage into HttpEntity):
> 
> BasicHttpEntity basicHttpEntity = new BasicHttpEntity();
> basicHttpEntity.setContent(mimeMessage.getInputStream());
> request.setEntity(basicHttpEntity);
> 
> Note: for scalability reasons I want to avoid using the "ByteArrayEntity"
> (I want to work with streams).
> 
> Thank You
> 
> Sincerely,
> Manjiri

Manjiri

If you can afford converting MimeMessage to another object you could use
MultipartEntity shipped with HttpMime (a module of HttpClient). If you
can't, your best option is to build a custom HttpEntity class along the
lines of MultipartEntity

http://hc.apache.org/httpcomponents-client-ga/httpmime/xref/org/apache/http/entity/mime/MultipartEntity.html

Oleg


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message