You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by khiem nguyen <kh...@googlemail.com> on 2011/04/30 01:13:14 UTC
throttlling download traffic
Hi,
i want to throttle the download-traffic/bandwidth with httpclient. Googling
around doesn't takes me further.
1 of the found options is using Thread.sleep(time) while reading from
inputstream.
looking into the source-code, i think i'll have to extends
SocketHttpClientConnection, go to SocketInputBuffer where i can use the
built-in TransportMetrics to set/reset the transferered traffic & put the
Thread.sleep there.
but it couldnt figure out how to do this quick from defaulthttpclient & how
to "wire" things together.
is this this approach correct ? if yes , it would be great if someone could
give me some clues about this.
& what about sslsocket ? do i have also have to touch schemefactory ?
is there any other options /suggestions
thanx alot
Re: throttlling download traffic
Posted by khiem nguyen <kh...@googlemail.com>.
thanx alot for the hints. u're always soooo helpfull
khiemu
On Sat, Apr 30, 2011 at 1:29 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
> On Sat, 2011-04-30 at 01:13 +0200, khiem nguyen wrote:
> > Hi,
> >
> > i want to throttle the download-traffic/bandwidth with httpclient.
> Googling
> > around doesn't takes me further.
> > 1 of the found options is using Thread.sleep(time) while reading from
> > inputstream.
> > looking into the source-code, i think i'll have to extends
> > SocketHttpClientConnection, go to SocketInputBuffer where i can use the
> > built-in TransportMetrics to set/reset the transferered traffic & put the
> > Thread.sleep there.
> > but it couldnt figure out how to do this quick from defaulthttpclient &
> how
> > to "wire" things together.
> > is this this approach correct ? if yes , it would be great if someone
> could
> > give me some clues about this.
> >
> > & what about sslsocket ? do i have also have to touch schemefactory ?
> >
> > is there any other options /suggestions
> >
> > thanx alot
>
>
>
> Probably the best (or the easiest) approach is to do the I/O throttling
> on the socket level. You would need to implement a custom Socket class
> and plug it in using a custom SchemeSocketFactory.
>
> Actually you can borrow most of the code from JMeter's Slow* classes:
>
>
> http://svn.apache.org/repos/asf/jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/SlowSocket.java
>
> http://svn.apache.org/repos/asf/jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/SlowSSLSocket.java
>
> http://svn.apache.org/repos/asf/jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/SlowInputStream.java
>
> http://svn.apache.org/repos/asf/jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/SlowOutputStream.java
>
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>
Re: throttlling download traffic
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sat, 2011-04-30 at 01:13 +0200, khiem nguyen wrote:
> Hi,
>
> i want to throttle the download-traffic/bandwidth with httpclient. Googling
> around doesn't takes me further.
> 1 of the found options is using Thread.sleep(time) while reading from
> inputstream.
> looking into the source-code, i think i'll have to extends
> SocketHttpClientConnection, go to SocketInputBuffer where i can use the
> built-in TransportMetrics to set/reset the transferered traffic & put the
> Thread.sleep there.
> but it couldnt figure out how to do this quick from defaulthttpclient & how
> to "wire" things together.
> is this this approach correct ? if yes , it would be great if someone could
> give me some clues about this.
>
> & what about sslsocket ? do i have also have to touch schemefactory ?
>
> is there any other options /suggestions
>
> thanx alot
Probably the best (or the easiest) approach is to do the I/O throttling
on the socket level. You would need to implement a custom Socket class
and plug it in using a custom SchemeSocketFactory.
Actually you can borrow most of the code from JMeter's Slow* classes:
http://svn.apache.org/repos/asf/jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/SlowSocket.java
http://svn.apache.org/repos/asf/jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/SlowSSLSocket.java
http://svn.apache.org/repos/asf/jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/SlowInputStream.java
http://svn.apache.org/repos/asf/jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/SlowOutputStream.java
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org