How do I use Fiddler to modify the status code in an HTTP response?

后端 未结 3 1115
北恋
北恋 2021-01-30 05:22

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 have Fiddler 2

3条回答
  •  一整个雨季
    2021-01-30 05:59

    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. 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. Right next to the green Run to Completion button (which you click to send the response) there's a dropdown that lets you choose some default response types.
    2. Or, on the Headers inspector, change the response code & message in the textbox at the top.
    3. Or, click the "Raw" inspector and mess with the raw response to do arbitrary things to it. Also a good way to see what your client does when it gets a malformed response, which you'll probably test accidentally :)

提交回复
热议问题