On Sun, 2017-06-04 at 15:03 +0000, Dan Wlodarski wrote:
> To whom it may concern:
> 
> Issue: HttpClient API does not support chunking multipart
> HttpEntities.
> Clients making SOAP requests to a mock SOAP with attachments (SWA)
> server
> are failing (specifically, Apache-based Java clients are throwing
> org.apache.http.NoHttpResponseExceptions) when the attachment in the
> response is large (>2 MiB). Small attachments are transmitted without
> throwing any exceptions. HTTP Content-Length header is correct.
> 
> Use case: Multithreaded SOAP server capable of transmitting SWA
> responses of
> arbitrary content length
> 
> Libraries: HttpCore v4.4.6 + HttpMime v4.5.3
> 
> Example server source for error replication is available at:
> https://pastebin.com/2Hzdhpt3
> 
> Error replication:
> 1. Build the above source with HttpCore v4.4.6 and HttpMime v4.5.3
> libraries
> (HttpMime is part of the HttpClient project).
> 2. Run the program with a sufficiently large (>2 MiB) binary file
> named
> "random.png.gz" with correct pathing and permissions (a readable
> directory
> sibling of the executable).
> 3. Send the server an arbitrary HTTP POST request via some third-
> party
> client. Note the failure to receive the large server-generated
> multipart
> result.
> 
> NB: SoapUI can be leveraged as an Apache-based Java client with
> precision
> logging.
> 
> Please advise.
> 

Dan,

You are mixing up non-blocking i/o transport and a blocking i/o entity
implementation. This is generally a bad idea as it cannot be done
efficiently without full or partial content buffering in memory.

If do not mind buffering the entire entity in memory, you can replaceĀ 
---
response.setEntity(responseEntity);
---

with
 
---
final ByteArrayOutputStream out = new ByteArrayOutputStream();
responseEntity.writeTo(out);
response.setEntity(new ByteArrayEntity(out.toByteArray()));
---

and your code will work just fine.

Oleg  


> Thanks,
> 
> Dan C. Wlodarski
> The Design Knowledge Company
> 3100 Presidential Drive
> Suite 103
> Fairborn, Ohio 45324
> 
> Phone: 937-427-4276 x175
> Fax: 937-427-1242
> dwlodar...@tdkc.com
> www.tdkc.com
> 
> P.S. This issue was originally submitted on 30 May, but did not
> appear in the archives. Assumed dropped.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
> For additional commands, e-mail: httpclient-users-h...@hc.apache.org
> 

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

Reply via email to