How to use Charles' rewrite tool only on certa

2019-02-27 23:30发布

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?

Rewrite Screen

3条回答
兄弟一词,经得起流年.
2楼-- · 2019-02-27 23:43

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.

查看更多
一夜七次
3楼-- · 2019-02-27 23:50

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]*\]

Rewrite Rule

查看更多
我欲成王,谁敢阻挡
4楼-- · 2019-02-27 23:51

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.

查看更多
登录 后发表回答