On Fri, 2013-11-08 at 09:45 -0800, Harold Rosenberg wrote: > Actually, one minor correction. In the second case, the exception stack is > actually slightly different. It is: > > The mpEntity isRepeatable = true > Exception in thread "main" java.lang.UnsupportedOperationException: Multipart > form entity does not implement #getContent() > at > org.apache.http.entity.mime.MultipartFormEntity.getContent(MultipartFormEntity.java:92) > > at > org.apache.http.entity.HttpEntityWrapper.getContent(HttpEntityWrapper.java:84) > > at > org.apache.http.entity.BufferedHttpEntity.getContent(BufferedHttpEntity.java:83) > > at Test.main(Test.java:440) > > So, in this case the exception happens because the call is being passed > through. In the stack trace from the other case, the exception seems to > happen when the BufferedHttpEntity tries to buffer the data. Does this mean > that there is no way to send a Multipart entity using the HttpAsyncClient? >
Harold That's the problem with trying to mix an asynchronous transport with an inherently blocking content producer. MultipartFormEntity can only produce its content using #writeTo method and cannot be used asynchronously. You basically have two options. (1) Write out entity content to ByteArrayOutputStream (or similar) and then create NByteArrayEntity using the resultant byte array. (2) Create multipart entity implementation that can produce its content asynchronously. Hope this helps Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
