Inspecting iPhone web requests with Charles on a Mac

Side-note: Craig wrote a similar blog post on this but using Fiddler, which only works on a Windows machine...

In case you are not aware, Charles is a web debugging proxy that you can use on your machine to inspect web requests that are happening live. This is a really useful tool if you're wanting to debug why a certain web request isn't coming back as expected or to see what headers are being sent with that request. Sometimes you are wanting to inspect the same issues on the iPhone but obviously you can't just fire up Charles on the device

To allow this to work, you will need to make sure that both the iPhone and machine running Charles are on the same network. By default Charles is set to listen out for any web requests on the desktop machine and is set to listen to external requests on port 8888. On the iPhone, you want to go into Settings -> Wi-Fi -> and then click the blue icon on the connected Wi-Fi connection.


 

This will take you to a more in depth view of your network setting, by scrolling down right to the bottom, you'll see HTTP Proxy settings which by default will be set to "Off". We will want to select "Manual" and fill in the server and port settings.

 

The server setting will be the IP address of the machine running Charles - you can either run the command 'ifconfig' in Terminal on the machine running Charles or open up the Network settings and check under status. For me, my IP address will be 192.168.1.68. And the port setting will be 8888 (the default port on Charles).

 

After entering in these values, the iPhone will now be waiting for a HTTP request to proxy through to Charles. To simply check this is working, open up Safari Mobile and enter in Google.com. You should noticed that Charles is now prompting you to Allow or Deny access from a remote host, this will be your iPhone so press Allow.

 

On your iPhone you should now see the Google homepage load up as expected and you will now also see the requests coming through on Charles too as per the image below.

 

Make sure you turn off the proxy after debugging otherwise your iPhone will keep looking to connect to the proxy whether it is there or not.

Hope this helps,

ChrisNTR

Published Sunday, July 18, 2010 10:39 PM by Chris Hardy (ChrisNTR)

Comments

No Comments