Ale*_*lex 3 regex proxy fiddler
我正在使用Fiddler拦截特定远程文件的请求,而我正在处理它们(因此我可以在本地调整它们而不触及已发布的内容).
即我使用这样的许多规则
match: regex:(?insx).+/some_file([?a-z0-9-=&]+\.)*
respond: c:\somepath\some_file
Run Code Online (Sandbox Code Playgroud)
这非常有效.
我现在要做的就是更进一步,这样做
match: regex:http://some_dummy_domain/(anything)?(anything)
respond: c:\somepath\(anything)?(anything)
Run Code Online (Sandbox Code Playgroud)
或者,用明文,
拦截任何对'some_dummy_domain'的http请求,进入'c:\ somepath'并使用最初请求的相同路径和名称获取文件.查询字符串应该通过.
一些方案进一步澄清:
http://some_domain/somefile --> c:\somepath\somefile
http://some_domain/path1/somefile --> c:\somepath\path1\somefile
http://some_domain/path1/somefile?querystring --> c:\somepath\path1\somefile?querystring
Run Code Online (Sandbox Code Playgroud)
我试图利用我已有的东西:
match: regex:(?insx).+//some_dummy_domain/([?a-z0-9-=&]+\.)*
respond: ...
Run Code Online (Sandbox Code Playgroud)
基本上,我正在寻找//some_dummy_domain/请求.这似乎在测试时正确匹配,但我想知道如何回应.
Fiddler可以在回复中使用匹配,我怎样才能正确设置?
我试图回应,c:\somepath\$1但Fiddler似乎逐字对待:
match: regex:(?insx).+//some_domain/([?a-z0-9-=&]+\.)*
respond: c:\somepath\$1
request: http://some_domain/index.html
response: c:\somepath\$1html <-----------
Run Code Online (Sandbox Code Playgroud)
问题是你insx在表达的前面使用; 这n意味着您需要明确命名的捕获组,这意味着$1不会自动创建组.您可以省略n或明确命名捕获组.
来自Fiddler书:
在操作文本中使用RegEx替换
Fiddler的AutoResponder允许您使用正则表达式组替换将匹配条件中的文本映射到操作文本.例如,规则:
匹配文本:REGEX:.+/assets/(.*)
操作文本:http://example.com/mockup/$1
...地图的请求http://example.com/assets/Test1.gif来http://example.com/mockup/Test1.gif.
以下规则:
匹配文字: REGEX:.+example\.com.*
行动文字: http://proxy.webdbg.com/p.cgi?url=$0
...重写入站URL,以便所有包含example.com的URL作为URL参数传递给页面proxy.webdbg.com.
匹配文字: REGEX:(?insx).+/assets/(?'fname'[^?]*).*
行动文本 C:\src\${fname}
...地图的请求http://example.com/?assets/img/1.png?bunnies来C:\src\?img\?1.png.