5.1 The second day of the holiday, still nest at home, but today a guest, my good friend “Xiao ge” to see xiao Bao, at noon to drink, each “boast” for a while, talk about their career development, work encountered problems, and the future planning.

He is in charge of the business in Beijing, including demand negotiation, research and development, project promotion and acceptance, etc. The company’s business is app terminal for many banks. He shared with me some of his experience in management, and I am really happy for him.

Charles is a package capture tool, and Postman is an API debugging tool. A few days ago, I tried to use Charles to grab Websocket messages, but it took a long time. Postman, too, installed the app version, had some problems, and wanted to share the process with friends who needed it.

Charles

Charles is an HTTP proxy /HTTP monitor/reverse proxy that allows developers to view all HTTP and SSL/HTTPS traffic between their machine and the Internet, including requests, responses, and HTTP headers (which contain cookies and cache information).

The basic principle is to set itself as a proxy server, and the browser, mobile phone app and other clients set the proxy to the port that Charles listens to. The client sends the request to Charles, and Charles then sends the request to the real server. When the result is returned, Charles forwards it to the browser, mobile phone and other clients.

The following describes the request fetching of various protocols, and the environment is as follows:

  • Using Android phone as the client, simulate sending various requests;
  • Install the Charles application on your Mac as a proxy server;
  • Grab a variety of requests of Mi Mall app;
  • Ensure that Android and Mac are connected to the same network;
configuration

The first step is to set the Charles agent, as long as the lower port is set:

Step 2: Configure your phone’s Wifi agent (different for each phone) :

Select the manual proxy, the host name is MAC, and the port number is the port configured in the first step. After the configuration is complete, the MAC terminal prompts you to Allow the access. Select Allow.

In this way, some requests of mi Mall app can be viewed:

Fetching HTTPS requests

To capture HTTPS requests, you need to configure a certificate as follows:

Step 1: Secure the Charles root certificate on the MAC:

Step 2: Save the Charles root certificate as cer, send it to the mobile phone, and install the certificate:

After the installation is complete, you can view the certificate in the security Settings:

Step 3: Enable the SSL proxy

After this setting, you can grab the HTTPS request without garbled content:

Grab the Websocket request

After version 3.11, webSocket fetching is supported as follows:

Do not know what reason, use the above wifi proxy configuration, can not grab websocket request, check many articles have no success, finally, see a word: some protocols will not pass wifi proxy, think of using global proxy app, should support Websocket protocol, finally verification is possible.

I have selected the Drony proxy app. Other proxy apps should also work. First, configure the proxy server as before:

Go to the Setting TAB and select Wi-Fi:

Find the network name used, click on Settings, and set it to the address and port of Charles:

After this setting, we can grab the WebSocket request:

Other Functions

Can also provide the following functions, here will not expand to say, there are also a lot of information on the Internet:

  • Analog slow network;
  • Modify the network request content and send the request several times;
  • Stress test servers;
  • Map function, which can request app to test environment;
  • Breakpoints function, when the specified network request occurs, Charles will intercept the request, you can temporarily modify the network request returned content in Charles;

For those interested, check out this article: Portal

Postman

Postman is an application for debugging and sending HTTP requests to web pages. It can be used to simulate get or POST requests or other debugging interfaces conveniently.

I have been using The Chrome App version before, but this version is not maintained recently, so I am prompted to use the app version. This tool is relatively easy to use, so I will talk about the features THAT I think are great.

Environmental management

The system has test environment and online environment, the request URL must be different, some parameters may also be different, you can switch different environment, dynamic change, so only need to configure the URL and parameters once.

With the above setting, you can use the environment variable in the URL configuration:

Collections

We can save our request and reset the request address and parameters without opening it:

The workspace

The new version provides workspace functionality that can be switched between different projects:

Grab the browser request

It can be automatically mapped to parameters and cookie information, corresponding to the interface that needs to be invoked after login. You can log in to the browser now, and you can automatically set cookie information by crawling.

Step 1: Postman enables the proxy port:

In the second step, the browser sets the proxy to the port enabled in the first step:

I set it up with the browser plug-in SwitchyOmega so that when I visit the site in my browser, it will show up in Postman’s History:

Please scan the qr code below and follow my wechat official account to share my work, study and life