On Fri, 2015-04-10 at 22:58 -0700, natl wrote: > As mentioned in > http://mail-archives.apache.org/mod_mbox/hc-httpclient-users/201206.mbox/%3C1339619106.2755.17.camel@ubuntu%3E, > I understand that HttpClient does not have write timeout. However, I ran > into a situation when I upload a large file to a bad written service where > if it cannot read the data with a specific time, it will write the response > back to the client with 408 timeout. However, it will stop reading more data > from the client. This causes Entity.writeTo(OutputStream) to get stuck even > though the response has been received. I wonder whether there is any good > workaround to this one apart from interrupting the thread based on the the > content length. I'd rather prefer the mechanism similar to > socket.setSoTimeout() where the call will fail as soon as a write cannot be > completed within a specific timeframe. > > One thing I notice is that SocketOutputStream.write / SocketInputStream.read > cannot be interrupted. So even though you have another thread waiting for > timeout and then trying to interrupt the thread, you won't be able to do so > with Socket API. > > Thanks, >
Try using the async version of HttpClient which can handle out of sequence response messages http://hc.apache.org/httpcomponents-asyncclient-4.0.x/index.html http://hc.apache.org/httpcomponents-asyncclient-4.0.x/examples.html http://hc.apache.org/httpcomponents-asyncclient-4.0.x/httpasyncclient/examples/org/apache/http/examples/nio/client/ZeroCopyHttpExchange.java Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org For additional commands, e-mail: httpclient-users-h...@hc.apache.org