How to change response body with Charles? - charles-proxy

I am using Charles (http://www.charlesproxy.com) to debug my HTTP requests and now I run into an issue where I am receiving json response which I need to edit to see how my app behaves.
I was looking at Rewrite option but can't really figure out how to change it. Ideal would be to load whole response from disk.
Any ideas how to accomplish this? Thank you.

The Map Local tool is probably what you're looking for. Access via menu Tools | Map Local.... Note, you may need a corresponding rewrite rule (Tools | Rewrite...) to ensure the mime type of your response served from disk and the type your application is expecting. But recent versions of Charles may set the type automatically.

Share how to Enable breakpoints, then change response.
request the link firstly. then enable breakpoint > in the http request right click > choose Breakpoints
2. Menu Proxy > Breakpoints Settings > double click the request link
3. change the Scheme GET/POST > Query *
4. modify the request, change the tab Edit Request > you can change the URL, Headers, Cookies, etc > then click the Execute
5. edit the response: choose tab Edit Response > change the response > click the Execute
Enjoy it. You make it.

Charles Proxy change response
As was mentioned Charles Proxy(4.2.8 version) allows you to change response body using different approaches:
Map Local Tool ⌘ command + ⌥ option + L - Use local files to serve remote location
Map Remote Tool ⌘ command + ⌥ option + M - Modify the request location to map one remote location to another
Rewrite Tool ⌘ command + ⌥option + R - Modify requests and responses as they pass through Charles
Breakpoints Tool ⌘ command + ⇧ shift + K - Intercept and edit requests and responses before they are sent and received
Read more here

Enable breakpoints, then change response. You should press continue/send request to send it before tweak response.

Related

Charles Proxy Not Showing Same as Network on Browser

I went to browser and went to inspect element (F12) and chose Network, however I'm seeing more in Network than I see in Charles. I went to sequence in Charles and most of the methods I'm seeing there is just CONNECT, a few GET, and a few POST. However in the network section (just viewing JS), I am seeing a bunch of POST methods that Charles isn't showing. Is Charles supposed to show that or is there a reason it's not showing?
Probably your browser is caching many of those resources not appearing in Charles. You can avoid cache by:
Refresh your page with Ctrl + F5, or
Clear caché (in most browsers Ctrl + Shift + Supr), or
Use the incognito mode (in most browsers: Ctrl + Shift + N), or
If using Chrome: open the inspector and select "Disable cache" under the network tab.

Persistently Filtering Out Application Traffic in Fiddler

Whenever I start Fiddler, I see traffic from all of the applications on my system but it's very rarely the case that I want this. Usually what I want is to only see requests made by applications I am debugging. In order to achieve this, I leave Fiddler running all the time and whenever I want to see what happened with a request I can just open it up and see.
I can filter requests by right-clicking on an entry -> Filter -> Hide '<application name>'. Although this works fine, it is cleared when Fiddler is restarted.
How can I persist filters that filter out traffic from a certain application?
I tried using the Filters tab but this is very limited and one of the missing features is what I detailed above.
This can be achieved by creating custom rules. In order to do this, in Fiddler, go to Rules -> Customize Rules. You can choose Yes to install the FiddlerScript Editor plugin if you want but this is not necessary. Just click No when asked and a file named CustomRules.js will be opened using Notepad.
This file allows you to program all sorts of rules into Fiddler, from adding headers to outgoing requests to monitoring the time taken for a response to be received. Further details on it can be found here.
In order to filter out a certain application, scroll down to the OnBeforeRequest method and paste the following code in:
if (oSession["X-PROCESSINFO"] && (
oSession["X-PROCESSINFO"].StartsWith("firefox") ||
oSession["X-PROCESSINFO"].StartsWith("outlook") ||
false))
{
oSession["ui-hide"] = "FiddlerScript> Hiding unimportant process";
}
This piece of code tells Fiddler to hide all requests coming from Mozilla Firefox or Microsoft Outlook. If you want to add / update / delete any application here, all you need to do is copy / update / delete lines that contain the StartsWith method.
The first condition will filter out all the requests that do not come from an application. This is the case for requests made from Fiddler's Composer tab.

Advanced REST Client: adding query parameters

Advanced REST Client seems like a neat REST client implementation to try REST-APIs.
But, I can't find how I can add query parameters to the URI of the API, but without putting it up the with the URI itself.
for example, to generate some URL like
https://api.example.com/v2/users/?age=25&fanOf=lakers
i want to add parameters like "age"=25 and "fanOf"="lakers".
i know it's there somewhere but can't find it plainly on, otherwise intuitive interface, `Advanced REST client".
After a bit of failed exploration on Internet & SO of-course, got it from a tip of a co-worker.
The option opens up by clicking the down-arrow on the left-side of the url-box.
Screenshot with new version 12.1.4 of ARC client

fiddler autoresponder not working

I added a rule (flash file), specified the new flash file I want fiddler to respond with (use instead of the browser one). I've cleared my browser cache, and every time I play the stream, the browser flash file is captured again (instead of auto-responding) with the one saved already!!!
It used to work just fine, but now it appears as if the auto-responder (although checked) is not working at all...it's just a pass-through!!!
As explained in the forum post where you asked the same question
There are three possibilities:
1> The AutoResponder itself is disabled (checkbox at the top)
2> The AutoResponder rule is disabled (checkbox at the left of the rule)
3> The rule you've written doesn't match the target request's URL.
Sharing a screenshot of Fiddler might help me tell you which problem you're encountering.
On the top of the list EricLaw gave in the previous answer, I add a new one:
You need to ensure your Fidler has the "Capturing Traffic" mode enabled. Either press F12 or go to "File" -> "Capture Traffic" and make sure you have a "Capturing.." icon on your left bottom corner.
I had a similar issue, and I solved it by enabling decryption of HTTPS traffic.
You can do this by going to Tools > Options > , then check Decrypt HTTPS Traffic
I had the same problem. I drag-dropped from the left, "main", window into the autoresponder so the "request matches..." column auto-populated. As a sanity check I unchecked "unmatched requests passthrough" to ensure that the match rule was indeed picking it up. If it hadn't nothing would appear in the main window at all. But it did appear so the rule was matching.
The issue with Fiddler is in the "then respond with..." column. Right-click for "Edit Response...", edit the response in the popup window of tabs, press Save, close the box.
When you retry your URL, your edited response isn't returned. Fiddler returns the original response. Even if you Edit Response again, it'll show what you typed in, but it never actually returns it.
To fix, you have to save the intended response to a file on your hard drive and edit it there.

GWT Frame not working in Mozilla Firefox or in Google chrome, but working fine in IE

I am trying to download a file from server. The normal GWT RPC call doesnot allow me to do that, and hence I wrote a servlet to do that job for me. From the client side, I am creating a Frame object, and I set the servlet URL in it, and add that frame Object in my root panel.
When I execute this in IE, a window pops up asking for Save/Open file.
But when I execute the same in a Firefox or a Google Chrome browser, nothing is happing.
I am not getting any request on my servlet/server side.
Here is a slice of the code :-
String servletUrl = "http://localhost:13080/Browser/ui/dataExportServlet?level=ZERO";
Frame frame = new Frame(servletUrl);
frame.setVisible(false);
RootPanel.get().add(frame);
So, can someone please help me out.
This might be related to same origin policy.
Are both servlet and webapp running on port 13080?
If they differ, SOP might fail this.
If I understand correctly, IE has a more relaxed policy so it might work there but not in chrome.
See http://en.wikipedia.org/wiki/Same_origin_policy and Can I disable SOP (Same Origin Policy) on any browser for development?
In Chrome, you can use the Developer Tools (CTRL + SHIFT + I) to check if the IFrame is being added to the HTML, and if the frame's source is being set properly. You should also be able to see what content has been loaded into the iframe.
Alternately, set a breakpoint in your servlet to see if the iframe is being hit at all from Chrome.
I got the solution for this issue.
I removed the frames and added the following code :-
com.google.gwt.user.client.Window.open(url, "CSVDownload", "");
Now, this opens a new browser window, and then I get the pop-up to open/save the server side file in all 3 web-browsers. (IE, Mozilla FireFox, Chrome).
Thanks a lot!!!