From a537f19f3307e156042d7e7d5a261af3ddf574ac Mon Sep 17 00:00:00 2001 From: Jason Eric Klaes Hoetger Date: Sun, 12 Jul 2015 16:36:59 -0700 Subject: [PATCH] Allowing upstream and downstream bandwidth limits to be set in bytes per second in REST API --- .../bmp/proxy/bricks/ProxyResource.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/browsermob-rest/src/main/java/net/lightbody/bmp/proxy/bricks/ProxyResource.java b/browsermob-rest/src/main/java/net/lightbody/bmp/proxy/bricks/ProxyResource.java index fbd471734..ee4e6c54b 100644 --- a/browsermob-rest/src/main/java/net/lightbody/bmp/proxy/bricks/ProxyResource.java +++ b/browsermob-rest/src/main/java/net/lightbody/bmp/proxy/bricks/ProxyResource.java @@ -403,6 +403,14 @@ public Reply limit(@Named("port") int port, Request request) { streamManager.enable(); } catch (NumberFormatException e) { } } + + String upstreamBps = request.param("upstreamBps"); + if (upstreamBps != null) { + try { + ((BrowserMobProxy) proxy).setWriteBandwidthLimit(Integer.parseInt(upstreamBps)); + } catch (NumberFormatException e) {} + } + String downstreamKbps = request.param("downstreamKbps"); if (downstreamKbps != null) { try { @@ -410,6 +418,14 @@ public Reply limit(@Named("port") int port, Request request) { streamManager.enable(); } catch (NumberFormatException e) { } } + + String downstreamBps = request.param("downstreamBps"); + if (downstreamBps != null) { + try { + ((BrowserMobProxy) proxy).setReadBandwidthLimit(Integer.parseInt(downstreamBps)); + } catch (NumberFormatException e) {} + } + String upstreamMaxKB = request.param("upstreamMaxKB"); if (upstreamMaxKB != null) { try {