This package was approved by moderator ferventcoder on 1/30/2016. Charles is an HTTP proxy / HTTP monitor / Reverse Proxy that enables a developer to view all of the HTTP and SSL / HTTPS traffic between their machine and the Internet. Download Charles. The latest version of Charles is 4.2.7. Read the Release Notes. Paid Upgrade for Charles 3 to Charles 4. Charles 4 was a major update to Charles 3, and it is a paid upgrade.
Moviestarplanet
Active3 years, 4 months ago
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.
However, if I want to automate it via the 'Rewrite' tool, I'm stuck, it seems that you cannot modify the status code:
Do you know if I'm missing something?
ThomasThomas49011 gold badge44 silver badges1111 bronze badges
4 Answers
An Update: Version 3.8 of Charles Proxy was just released, with the ability to rewrite the status. From the release notes:
- Rewrite tool: allow rewriting of response status
This version's rewrite UI adds a new 'Response Status' rule type:
Marc LiyanageMarc Liyanage3,06922 gold badges2323 silver badges2525 bronze badges
Using Charles 3.8+, you can rewrite the status code.
In the rewrite tool, select 'Type: response status'.In the match fields and replace fields, be aware that Charles expects the incoming and rewritten statuses to match the format
'd{3} .*'
. This means that your rewritten status must have a message portion in addition to the numeric status code.For example:
Match value: 201 .*
Replace value: 502 Bad Gateway
Omitting the message from the replace value will result in no rewrite of the status line.You can see Charles' rewrite tool output messages in the Notes section of each call's summary.
Download Charles Proxy 3.10.1
Marc KubischtaMarc Kubischta
![Charles Proxy 3.10.1 Charles Proxy 3.10.1](/uploads/1/2/6/0/126010904/196025187.png)
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:
To hook it into the proxy, I run
mitmdump
like this: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.
Maximilian Hils4,01733 gold badges1414 silver badges3131 bronze badges
Marc LiyanageMarc Liyanage3,06922 gold badges2323 silver badges2525 bronze badges
Final Edit: Marc Liyanage's answer is the most correct for this question now.
No, you're not, I don't think it is possible to rewrite a status code.
I cannot add this as a comment (new user) but one workaround is:
- Create resources on a server that will return the codes you need, or find ones that do.
- Use the Map Remote feature, mapping to the resource that returns the code.
I've tried using Map Local, which would be perfect for this, but Charles adds it's own 200 OK status code to all files returned.
Charles Proxy 3.10.1 Download
Edit: Also you can use breakpoints on individual responses and modify the code.
David BoydellDavid Boydell