Fiddler:在哪里为 m_SimulateModem 添加 IF 语句?

Fiddler: Where to add IF statement for m_SimulateModem?

我想在 fiddler 中添加以下代码:

if (m_SimulateModem) {
    // Delay sends by 300ms per KB uploaded.
    oSession["request-trickle-delay"] = "300"; 
    // Delay receives by 150ms per KB downloaded.
    oSession["response-trickle-delay"] = "150"; 
}

我已经将 m_simulatemodem 设置为 true (var m_SimulateModem: boolean = true;),但我不知道应该在哪个事件上添加上面的代码段。

我尝试将它添加到 static function OnBeforeRequest(oSession: Session) 中,但它似乎没有任何作用。

基本上,我想模拟一个非常低的速度,以便任何正在使用的浏览器returns 连接超时ERR_CONNECTION_TIMED_OUT

Fiddler Performance Testing guide 明确指出 request-trickle-delay 必须在 OnBeforerequest 中使用:

Simulate modem uploads (add to OnBeforeRequest function)

`oSession["request-trickle-delay"] = "300";`

并且 response-trickle-delay 必须在 OnBeforeResponse 中使用:

To test application performance, add rules using FiddlerScript to the OnBeforeResponse function (except where noted). For example:

oSession["response-trickle-delay"] = "150";

不过,我假设使用这两种设置,您不会强制浏览器 运行 变成 ERR_CONNECTION_TIMED_OUT

300 的设置意味着每 300 毫秒 1 KB,因此我们最终得到大约每秒 3KB 或 ~2400 KBit。这是 20 世纪最后十年的老式调制解调器的连接速度。这可能需要一些时间,但只要数据流持续交付,所有请求都会起作用。

当客户端尝试联系服务器但服务器未响应 TCP 请求时(例如,因为端口未侦听或服务器被过多流量阻塞),会发生连接超时。

最简单的模拟方法是使用现有服务器并重写服务器端口,这样请求就会超时,因为没有服务器侦听指定端口:

// make requests to www.example.org end up in a connection time-out
if (oSession.HostnameIs("www.example.org")) {
  oSession.hostname="www.example.org:12345";
}