DEV Community

loading...

Use Breakpoint to intercept and edit HTTP requests/responses

renee profile image Renée Updated on ・4 min read

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 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 so that we are able to see HTTPs content

Requests coming from my remote device<br>

To be more focused, let’s use Pin to isolate two endpoints “api.unsplash.com/me” & “api.unsplash.com/search” for our testing scenarios

Use Pin to isolate endpoints

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

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

Alt Text

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

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

Option 2: Right click

Another option to define matching rule is to Right Click the selected URL (endpoint) -> select Tools -> Breakpoint

Alt Text

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

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

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

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

Alt Text

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

Alt Text

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

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

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

Alt Text

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 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/

Discussion (0)

pic
Editor guide