Hi Stuart<br><br>Thanks a lot for the ResponseRateLimitingHandler. I played a little bit with this handler and do have some questions.<br><br>I added some trace logs in order to understand the logic. Of course, I didn't understand everything;-) May you will correct me.<br><br>First, I tested the download response with a 1 MBytes file. The response limit was set to 100000 Bytes/s. This should download the whole file in about 10s but the result was 18s.<br>Then, I started to dig into the handler.<br><br>How I cReated the handler.<br>final ResponseRateLimitingHandler responseLimiter = new ResponseRateLimitingHandler(proxy, 100000, 1, TimeUnit.SECONDS);<br><br>The trace logs showed me this (with the settings above):<br><ul><li>the handler writes chunks as big as the buffer is defined, I think on my machine 16KBytes.</li><li>it repeats this until the bytes written are greater than the rate limit.</li><li>then, the handler calculates the time to sleep until the next chunks can be written.</li></ul><p>Problem 1: The handler writes always more than the specified limit. Because of this, the handler calculates n * units for the time to sleep. So, in my test the handler slept always 2s instead of 1s.</p><p>Problem 2: The size of the chunks is probably too static. I think the chunks should be size relatively to the rate limit.</p><p><br></p><p>I changed the handler slightly in this way:</p><ul><li>I introduced along to the existing parameters also a chunkSize.</li><li>canSend(): if (byteCount &lt; (bytes - chunks)) {&nbsp;&nbsp;&nbsp;&nbsp; return true;&nbsp;&nbsp;&nbsp; }&nbsp; // it doesn't write anymore than allowed</li><li>handleWritten(long written): nextSendTime = startTime + time;&nbsp; // instead of: nextSendTime = startTime + (units * time);</li><li>writeFinal and transferFrom writes not more than bytes &lt;= chunkSize.</li></ul><p>This changes gave me the expected result of about 10s download time.</p><p>This is quite a long mail :-) It could be still a mistake I did. Let me know what you think.</p><p>Regards, Ralf<br></p><p><br></p><p><br></p>