Use Breakpoint to intercept and edit HTTP requests/responses
Tags: ios, android, sslproxying, debugtools
Published: 2019-09-17 08:12:45

---
title: Use Breakpoint to intercept and edit HTTP requests/responses
published: true
description: 
tags: #ios #android #sslproxying #debugtools
---

In software development, a breakpoint is known as “an intentional stopping or pausing place” where you can examine, edit API requests or responses and even decide whether to block it or allow it to proceed. This blog demonstrates how I use Proxyman Breakpoint tool to manipulate those API calls for debugging purposes.

---

### When to use Breakpoint

Basically, if you enable Breakpoint for request, [Proxyman](https://proxyman.io/) will stop the request before it goes to your server. If you enable Breakpoint for response, it will stop the response before it goes to your app. Thus, you can modify such requests/ responses to test UI errors or certain back end functionalities (including security vulnerabilities). In this blog, just take 2 simple examples to see how Breakpoint works:
* Example 1: Change user’s search query to see how the app behaves (Modify request)
* Example 2: Change user name and avatar in the Response to see if the UI can handle long messages (Modify response)

### Install Proxyman Certificate on remote device
Before we start, let’s [install Proxyman Certificate on my iOS device](https://proxyman.io/blog/2019/06/How-I-use-Proxyman-to-see-HTTP-requests-responses-on-my-iPhone.html) so that we are able to see HTTPs content

![Requests coming from my remote device
](https://thepracticaldev.s3.amazonaws.com/i/0zo0swwujd41s2187bed.png)

To be more focused, let’s use [Pin](https://proxyman.io/blog/2019/06/How-I-use-Proxyman-to-see-HTTP-requests-responses-on-my-iPhone.html) to isolate two endpoints **“api.unsplash.com/me”** & **“api.unsplash.com/search”** for our testing scenarios

![Use Pin to isolate endpoints](https://thepracticaldev.s3.amazonaws.com/i/sfdojwj7db64ozbdmkda.png)

### Define Matching Rules with Endpoints
Now it’s time for us to define how Breakpoint captures *out-going* requests and *in-coming* responses. Basically, these conditions can be setup by two ways:

#### Option 1: Menu bar
From **Menu bar** -> select **Tools** -> select **Breakpoint** -> **Rules**. Then a Breakpoint rules window will pop-up so that we can define matching conditions

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/izufvre3x71g2cp5ztla.png)

To add new rule, you can click the **“+”** button at the bottom left corner of the window

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/qi35uxfp6gfojm7bg35j.png)

As we only want to change the search query for the first scenario, let’s type in the endpoint **“api.unsplash.com/search”** and select “Request” only

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/juqat029aqh57pg0cae9.png)

After hitting **“Add”** button, we know that any out-going requests to that endpoint would be stopped by the Breakpoint from now on :)

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/4yiauhybjnnsibmy0x2z.png)

#### Option 2: Right click
Another option to define matching rule is to **Right Click** the selected URL (endpoint) -> select **Tools** -> **Breakpoint**

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/qd3i289mk3wea7x00ct4.png)

As Proxyman auto-use the selected endpoint as the condition, we should see the endpoint **“api.unsplash.com/me”** is auto-filled as below

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/wfc4xsmus1tzvjks0qx6.png)

As we only want to change Response, let’s select “Response” for the second scenario. After hitting **“Done”** button, that new rule has been added up to the Breakpoint rules window

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/sz3ofrull9rhyd2eyv3f.png)

With that all set up, it’s time to modify requests/responses to see how our app behaves :)

### Modify requests with Breakpoint
First, let’s run the Unsplash application; then from *Search box*, type in the keyword *“eat clean”* to navigate to the endpoint that triggers Breakpoint. As soon as the API call is captured, a **Breakpoints window** would pop-up so that we can modify the query

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/di7agyht2rljvrlc99i4.png)

Let’s change our search query from *“eat clean”* to *“mountain”*…

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/ktrss4fqarrpgg38h4z8.png)

… and instead of showing *“eat clean”* images as origin request (Left), the app render *“mountain”* images (Right) as we expect :)

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/ryoiufv15ractbl1ghnx.png)

### Modify responses with Breakpoint
Similarly to editing the request, we are able to edit the content of response also. Let’s just re-open the Unsplash app to call the endpoint **“api.unsplash.com/me”**

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/4axrmzamx22y8r25y7rp.png)

Once the API response is captured, we could change the username and avatar to see how our app handles. Here I edit the user name to be longer and update the avatar

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/8qrjg2176mn5pxzd3bgl.png)

Once hitting **“Execute”**, the modified Profile shows up with new username and avatar instead of original ones :)

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/4ftfsu9npwubm9khvi81.png)

### What’s next?
With Breakpoint, it is possible for you to change any parts of the API request/response, but please bear in mind that it might misbehave or crash when it doesn’t get the correct format it’s expecting to receive. With that being said, do not hesitate to experience and boost your productivity with this tool. Happy debugging :)


---
[Proxyman](https://proxyman.io/) is a high-performance macOS app, which enables developers to view HTTP/HTTPS requests from apps and domains on iOS device, iOS Simulator and Android devices. Check it out at https://proxyman.io/