如何使用Fiddler修改HTTP响应中的状态代码? [英] How do I use Fiddler to modify the status code in an HTTP response?

查看:714
本文介绍了如何使用Fiddler修改HTTP响应中的状态代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要测试一些我编写的客户端应用程序代码,以测试它对来自Web服务器的HTTP响应中返回的各种状态代码的处理。

I need to test some client application code I've written to test its' handling of various status codes returned in an HTTP response from a web server.

I安装了Fiddler 2(Web调试代理),我相信有一种方法可以使用这个应用程序修改响应,但我很难找到方法。这将是最方便的方式,因为它允许我保持客户端和服务器代码不被修改。

I have Fiddler 2 (Web Debugging Proxy) installed and I believe there's a way to modify responses using this application, but I'm struggling to find out how. This would be the most convenient way, as it would allow me to leave both client and server code unmodified.

任何人都可以协助,因为我想拦截HTTP响应从服务器发送到客户端并在到达客户端之前修改状态代码?

Can anyone assist as I'd like to intercept the HTTP response being sent from server to client and modify the status code before it reaches the client?

任何建议都将不胜感激。

Any advice would be much appreciated.

推荐答案

好的,所以我假设你已经能够监控你的客户端/服务器流量了。您要做的是在响应上设置一个断点,然后在将其发送到客户端之前摆弄它。

Ok, so I assume that you're already able to monitor your client/server traffic. What you want to do is set a breakpoint on the response then fiddle with it before sending it on to the client.

以下是几种不同的方法:

Here are a couple of different ways to do that:


  1. 规则>自动断点>回复后

  2. 在quickexec框中(黑色框中的黑框)底部)输入bpafter yourpage.svc。现在Fiddler将在对包含yourpage.svc的任何URL的所有请求之前停在断点处。键入bpafter,没有参数来清除断点。

  3. 使用FiddlerScript以编程方式篡改响应。 FiddlerScript的最佳文档在官方网站上: http://www.fiddler2.com/Fiddler/dev /

  1. Rules > Automatic Breakpoints > After Responses
  2. In the quickexec box (the black box at the bottom) type "bpafter yourpage.svc". Now Fiddler will stop at a breakpoint before all requests to any URL that contains "yourpage.svc". Type "bpafter" with no parameters to clear the breakpoint.
  3. Programmatically tamper with the response using FiddlerScript. The best documentation for FiddlerScript is on the official site: http://www.fiddler2.com/Fiddler/dev/

一旦你在断点处停止了响应,只需双击它就可以在检查员中打开它。你现在有几个选择:

Once you've got a response stopped at the breakpoint, just double click it to open it in the inspectors. You've got a couple of options now:


  1. 在绿色的Run to Completion按钮旁边(你点击发送回复)有一个下拉列表可以让你选择一些默认的响应类型。

  2. 或者,在Headers检查器上,更改响应代码&顶部文本框中的消息。

  3. 或者,单击原始检查器并弄乱原始响应以对其执行任意操作。同样是一个很好的方法来查看客户端在收到格式错误的响应时会做什么,您可能会意外地进行测试:)

这篇关于如何使用Fiddler修改HTTP响应中的状态代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆