Summary of how charles modifies requests and responses (multiple pictures are very detailed)

The basic usage of charles will not be repeated. This article mainly summarizes several ways to modify requests and responses.

The test request used in this article is the local interface: http://sunset.com:8000/file/avatar/goods-001.jpg?name=test&age=20

  1. Modify the request message through compose, which is similar to postman's simulated request

    Select the request intercepted by charles, right click –>compose

    insert image description here
    insert image description here

    As shown in the figure: Label 1 can see the parameters of this request, which can be modified here; Label 2 can add and delete query parameters; Label 3 executes the modified request;

  2. Modify the request and response through rewrite

    Click the menu tools–>rewrite to open the Rewrite Setting window

    insert image description here
    insert image description here
    insert image description here

    Then we test the request in the browser

    insert image description here
    The test only modifies the response body data, and this rewrite can also modify other types of data such as the response status code.

  3. Rewrite the response by mapping local files

    Select the request intercepted by charles, right click and select save response, which can be saved in .json format
    insert image description here

    Open the file you just saved and modify the data inside

    insert image description here

    Right-click the request again, select map local, and open the configuration window

    insert image description here
    insert image description here

    Then open the test in the browser, you can see the content we just modified.

    insert image description here

  4. Modify requests and responses through breakpoints

    Select the request intercepted by charles, right click and select breakpoints
    insert image description here

    Then use the browser to initiate the request again

    insert image description here

    After clicking execute, you can see the breakpoint and go to the response editor

    insert image description here

    After performing the operation, you can see that the response on the browser side has changed

    insert image description here
    Finish

Guess you like

Origin blog.csdn.net/mochenangel/article/details/118099793