Logo for tanaschita.com

Manipulating networking requests and responses with Charles

Learn how to use Charles breakpoints tool to change network data and test your iOS application.

07 Mar 2022 · 4 min read

Charles is a proxy server that enables us to view the networking traffic between the app and the internet.

In Quick guide on Charles Proxy for iOS development, we already looked at the features Charles has to offer and how to use them.

In this article, we are going to dive more deeper and look at the Charles breakpoints tool. It lets us intercept and manipulate requests and responses before they are passed through Charles.

Being able to manipulate response data is a great way to test how the app handles unexpected values. Let's get started.

Setting up a breakpoint

Each breakpoint in Charles matches a URL using location matching patterns and is also assigned to either the request, the response or both.

Sponsorship logo
Using Proxyman to inspect network traffic
Proxyman is a native debugging proxy that can act as a man-in-the-middle between your application and web server. You can use its powerful toolkit to inspect network calls and debug your application on Mac, iOS Simulator, or remote devices effortlessly.
CLICK TO LEARN MORE

The simplest way to enable a breakpoint is by selecting the URL and then clicking the breakpoint button in the top toolbar.

Enable breakpoints.
Enable breakpoints.

For more control, open Proxy -> Breakpoint Settings in the menu. Here, we see an overview of all the breakpoints that are set, can edit, remove them or add new ones.

Breakpoint settings.
Breakpoint settings.

When editing or adding a breakpoint, we are able to configure details like protocol, host, port, path patterns or wildcards. Here, we can also select whether the breakpoint should be assigned to the request, the response or both.

Editing request and response data

When a request hits a breakpoint, the breakpoints window automatically opens in Charles we can view and edit the data.

Edit request in Charles.
Edit request.

The same happens when a response hits a breakpoint.

Edit response.
Edit response.

After editing, we can use different action buttons on how Charles should proceed with the request or response. The following actions are available:

  • Execute: Applies any changes we made and lets the request or response proceed.
  • Abort: Blocks the request or response and sends an error message to the client.
  • Cancel: Discards any changes we made and lets the request or response proceed as originally received.

Conclusion

Charles breakpoint tool is an easy to use and powerful way to debug our applications.

Charles offers even more advanced tools like repeating, automatic rewrites, map local, map remote, cache, cookies control and more. Check out their official tools documentation to check those out.

Sponsorship logo
Using Proxyman to inspect network traffic
Proxyman is a native debugging proxy that can act as a man-in-the-middle between your application and web server. You can use its powerful toolkit to inspect network calls and debug your application on Mac, iOS Simulator, or remote devices effortlessly.
CLICK TO LEARN MORE

Newsletter

Image of a reading marmot
Subscribe

Like to support my work?

Say hi

Related tags

Articles with related topics

networking

tools

ios

Quick guide on Proxyman for iOS development

Learn how to use Proxyman to inspect network traffic for your iOS application.

04 Jul 2022 · 8 min read

Latest articles and tips

© 2022 tanaschita.com

Privacy policy

Impressum