问题
How can I test that a web app successfully falls back from one faulty back-end API to a secondary legacy API service?
Could Firebug or Chrome, or Fiddler do it?
How can I setup my client to return error responses for ajax calls to a certain URL pattern?
- Using HTTPS.
- I don't have control over the server-side.
- I want to err just certain ajax calls the remaining should work the same (pulling the network plug is not an option).
回答1:
Yes, Fiddler can do this easily. In Fiddler, click the AutoResponder tab. Create a new rule that specifies the behavior you want. For instance:
If request matches: webdbg.com/test/Service1
Then respond with: *drop
If Fiddler ever gets a request for the specified URL, it will immediately close the connection. Or you could set the response action to return a HTTP/5xx error, or use *reset
to TCP/IP RESET the connection.
See http://www.telerik.com/automated-testing-tools/blog/13-02-15/testing-html5-appcache-with-fiddler.aspx for more details.
来源:https://stackoverflow.com/questions/19154037/simulating-a-response-for-an-ajax-call-that-a-web-page-makes-web-testing