You can also configure other applications to use Charles as their HTTP or SOCKS proxy. This enables you to debug their activity through Charles as well.
You may find that a lot of applications respect your system proxy settings, which are autoconfigured by Charles. However some applications won’t, and you will have to manually configure them.
In Charles, go to the Proxy menu and choose Proxy Settings. This will show you the currently configured HTTP Proxy Port and SOCKS Proxy Port. Note down which one you want to use (probably HTTP Proxy).
The host name is 127.0.0.1 (your own computer) or the external address of your computer if you want to access Charles from another computer.
You can then configure your application’s proxy settings with that host name and port.
You can configure your Java application to use Charles in code or as command line arguments to the java executable.
System.setProperty("http.proxyHost", "127.0.0.1"); System.setProperty("http.proxyPort", "8888");
And for HTTPS as well. Note that you may also want to configure Java to trust Charles’s root certificate in this case (see SSL Debugging).
System.setProperty("https.proxyHost", "127.0.0.1"); System.setProperty("https.proxyPort", "8888");
For the source of this information, including more discussion and how to set these as command line arguments: http://java.sun.com/j2se/1.5.0/docs/guide/net/proxies.html
Also see this tutorial on integrating Charles with your Java application by a Charles user.
If you are developing an application using libcurl you can configure it to use Charles as its proxy server:
curl_easy_setopt(pCurl, CURLOPT_PROXY, "127.0.0.1"); curl_easy_setopt(pCurl, CURLOPT_PROXYPORT, 8888);
If you are using SSL you may like to disable the certificate verification during development, if you can’t get cURL to trust Charles’s CA certificate:
curl_easy_setopt(pCurl, CURLOPT_SSL_VERIFYPEER, 0);
Thanks to Michael Klische for sending in this information.