kdzwinel / betwixt

:zap: Web Debugging Proxy based on Chrome DevTools Network panel.
MIT License
4.54k stars 125 forks source link

Support for Throttling #9

Open kdzwinel opened 8 years ago

kdzwinel commented 8 years ago

IMO doing a simple setTimeout on the proxy server should work just fine for most cases.

MichielDeMey commented 8 years ago

Won't that only emulate high latency? Throttling is rather for restricting bandwidth, I believe.

kdzwinel commented 8 years ago

@MichielDeMey thanks for input! You are right - setTimeout will only emulate latency. I'm not sure how to correctly emulate bandwidth at this point, but I'd guess that it should be throttled somewhere around here (traffic-interceptor.js):

    res.write = function(chunk) {
        _write.apply(res, arguments);

We can split each received data chunk into multiple smaller ones.

samccone commented 8 years ago

http://thesmithfam.org/blog/2012/04/11/throttling-your-network-connection-on-mac-os-x/

maybe we can actually do it :)

kdzwinel commented 8 years ago

Note: to show the network throttling panel back again revert https://github.com/kdzwinel/betwixt/commit/c002175d9e1f32ff5c528a1af06a8c3cb665509e .

jessetan commented 8 years ago

You can use something like https://github.com/tjgq/node-stream-throttle (which uses https://github.com/jhurliman/node-rate-limiter) to throttle a stream.