Is it possible to rewrite a status code with Charles Proxy?

后端 未结 6 834
刺人心
刺人心 2021-01-30 15:57

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.

6条回答
  •  攒了一身酷
    2021-01-30 16:40

    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.

提交回复
热议问题