IPHONE HTTP CONNECTION DEBUGGING

IPHONE HTTP CONNECTION DEBUGGING

Nearly all iPhone applications take advantage of the device’s amazing internet connectivity. Whether its checking the balance of your bank account or using an interactive web application in Safari, there is a tangible level of connectedness. Wouldn’t it be great if you could watch, log, and edit the HTTP requests live as they happen from the comfort of your desktop? Not only is it possible, it is easier than you might think and doesn’t require jailbreaking your device! This article shows you how in just a few easy steps.

<soapbox>

May I take this opportunity to offer my highest recommendation for a wonderful piece of software called the Charles debugging proxy. The software allows you to view and edit HTTP requests that filter through its proxy server. It is secure, easy to install and configure, and runs on both Windows and OS X. Charles has become an essential tool in my web developer bag of tricks and I use it everyday.

You can download a free trial, but you won’t regret purchasing a license for only US $50.

http://www.charlesproxy.com

</soapbox>

This tutorial will focus on connecting iPhone applications with the Charles debugger

PREREQUISITES

  • A wireless LAN subnet to which your iPhone has access and is connected
  • A laptop or desktop machine on the same LAN subnet as your iPhone
  • Charles debugging proxy installed

There are two main areas of setup, the Charles proxy host, and the iPhone device.

PART 1 – CHARLES PROXY HOST SETUP

  1. Run Charles and verify that you have sufficiently enabled access through your system’s local firewall. Often this simply involves disabling the software firewall on your operating system. Charles needs to be listening on your LAN IP address and its default port is 8888. See your Operating System’s documentation for this specific procedure.
  2. Note your system’s IP address. In my case it is 10.45.200.127

PART 2 – IPHONE SETUP

  1. Download the charles SSL intermediate certificate

    http://www.charlesproxy.com/charles_ca_certificate.zip

  2. Extract the charles.cer file from the zip archive.

    At this point you have two ways you can install the charles.cer file on your device. You can either email it to yourself and open the attachment from the device. Or, you can post the file on a web server and request the certificate in Safari on the device. Either method will raise an Install prompt that looks like the one below:

    Charles Certificate Install

  3. Configure your iPhone to use a proxy server

    This step involves going to the Settings application and into the Wi-Fi section. There you will hopefully see an option for the Wireless AP name you are connected to.

    Go to: Settings -> Wi-Fi -> “Your Wireless AP Name”

    Once there, scroll to the bottom of the window and you should see settings options to configure a proxy host as below:

    Proxy Config

    Enter your Charles proxy host address and port in the inputs provided

    NOTE: Once you are done using the Proxy, you will have to set your HTTP Proxy setting to “Off” for your phone to return to normal function.

  4. Test the configuration

    Open Safari and visit a website. You should see a prompt on your Charles machine to authorize the connection (this keeps unauthorized users from using your Proxy server):

    Charles Authorization

    Once the connection has been authorized, voilá! You should now see your phone’s HTTP requests live in Charles. For even more detail, you can click on the “Sequence” view.

Several useful things you can do with Charles at this point:

  1. Save file requests to disk by right clicking and choosing “Save Response…”
  2. Edit and resend HTTP requests by clicking the “Edit” icon on the toolbar with a request selected
  3. Debug SSL connections
  4. Throttle and simulate 3G network speeds in order to view how your app may respond. See “Throttle Settings” under the Proxy menu option.

Charles Preview

Take a look at the Charles Documentation for other tips and tricks:

http://www.charlesproxy.com/documentation/using-charles/

Enjoy, and happy hacking!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值