使用 Fiddler 调试 Websocket

Debug Websocket with Fiddler

我正在尝试使用 fiddler 调试 websocket 框架,我使用下一个代码来实现它

class Handlers
{
    // ...

    static function OnWebSocketMessage(oMsg: WebSocketMessage)
    {
        // Modify a message's content
        var sPayload = oMsg.PayloadAsString();
        var pattern = "Hello, \([a-zA-Z]+\)!";
        var match = Regex.Match(sPayload, pattern);

        if (match.Success) {
            var pattern = "Hello, \([a-zA-Z]+\)!";
            var match = Regex.Match(sPayload, pattern);
            var who = match.Groups[1].ToString();

            var forgedWho = String.Format("FORGED-{0}", who);
            var changedPayload = sPayload.Replace(who, forgedWho);
            FiddlerApplication.Log.LogString(String.Format("Changing {0} to {1}", who, forgedWho));
            oMsg.SetPayload(changedPayload);
        }
    }
}

我正在尝试将 "FORGED" 添加到 Web 套接字消息中,但是当我尝试保存脚本时显示下一个错误

Error

错误显示 "The variable 'Regex' has not been declared" 但正则表达式是一个函数,你能帮我吗。

我从这里提取这段代码http://www.mopsled.com/2016/debug-websocket-connections/

添加import System.Text.RegularExpressions或直接使用System.Text.RegularExpressions.Regex.Match(sPayload, pattern)