Hi Stuart

Thanks a lot for the ResponseRateLimitingHandler. I played a little bit with this handler and do have some questions.

I added some trace logs in order to understand the logic. Of course, I didn't understand everything;-) May you will correct me.

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.
Then, I started to dig into the handler.

How I cReated the handler.
final ResponseRateLimitingHandler responseLimiter = new ResponseRateLimitingHandler(proxy, 100000, 1, TimeUnit.SECONDS);

The trace logs showed me this (with the settings above):

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.

Problem 2: The size of the chunks is probably too static. I think the chunks should be size relatively to the rate limit.


I changed the handler slightly in this way:

This changes gave me the expected result of about 10s download time.

This is quite a long mail :-) It could be still a mistake I did. Let me know what you think.

Regards, Ralf