I\'m using Charles Proxy to rewrite a response from an API for testing purpose.
If I set a breakpoint, I am allowed to completely rewrite the raw response as I wish.
This is not a direct answer to your question, but as noted in my comment above I was in the same situation and I found a solution using a different tool that works well for me.
Instead of Charles, I run mitmproxy, specifically mitmdump, with this short Python rewriting script:
#!/usr/bin/env python
def response(context, flow):
if '/somePath' not in flow.request.path:
return
flow.response.status_code = 404
To hook it into the proxy, I run mitmdump
like this:
mitmdump -s /path/to/rewriting-script.py
and it works great.
I'm on OS X and I configured the network interface's web proxy to 127.0.0.1 port 8080.