How to use Charles' rewrite tool only on certain methods?

允我心安 提交于 2019-12-08 22:29:37

问题


I'm using Charles' Rewrite Tool to change 200 responses to 400 in order to test failing API calls. However, the rewrite is triggering on the Options request. I'd like to only have it trigger on the Get or Post requests and allow the Options requests through. Is this possible using Charles?


回答1:


I think Charles does not have this option, which is really a pitty, because it seems to be easy to implement and it would open the doors to the API world.

I would suggest you to ask Karl (the author and main developer) for this new feature at the contact section of the site.




回答2:


We were able to work around the issue by assuming that OPTIONS would always return an empty body.

The below Regex values will match for GET (because it has a body) and not match for OPTIONS (because it doesn't have a body).

\{[\S\s]*\}

or

\[[\S\s]*\]




回答3:


We have this exact same need to mock API responses. Since the Rewrite tool doesn't support this feature, we have setup Breakpoints on the responses we want to mock, once the breakpoint is hit, we change the response to whatever we want. It works, but is less than ideal.



来源:https://stackoverflow.com/questions/52048842/how-to-use-charles-rewrite-tool-only-on-certain-methods

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!