Skip to content

Commit 8e9805d

Browse files
committed
Allow setting bandwidth limits after proxy has started
1 parent 83d1150 commit 8e9805d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

browsermob-core-littleproxy/src/main/java/net/lightbody/bmp/BrowserMobProxyServer.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -588,20 +588,21 @@ public Har endHar() {
588588

589589
@Override
590590
public void setReadBandwidthLimit(long bytesPerSecond) {
591+
this.readBandwidthLimitBps = bytesPerSecond;
592+
591593
if (isStarted()) {
592-
throw new IllegalStateException("LittleProxy implementation does not allow changes to read bandwidth limit after proxy has been started");
594+
proxyServer.setThrottle(this.readBandwidthLimitBps, this.writeBandwidthLimitBps);
593595
}
594596

595-
this.readBandwidthLimitBps = bytesPerSecond;
596597
}
597598

598599
@Override
599600
public void setWriteBandwidthLimit(long bytesPerSecond) {
601+
this.writeBandwidthLimitBps = bytesPerSecond;
602+
600603
if (isStarted()) {
601-
throw new IllegalStateException("LittleProxy implementation does not allow changes to write bandwidth limit after proxy has been started");
604+
proxyServer.setThrottle(this.readBandwidthLimitBps, this.writeBandwidthLimitBps);
602605
}
603-
604-
this.writeBandwidthLimitBps = bytesPerSecond;
605606
}
606607

607608
@Override

0 commit comments

Comments
 (0)