This is a creation in Article, where the information may have evolved or changed.
Original link: http://blog.phpor.me/note/2017/03/31/track-and-replay-http-request.html
Client engineer: "The XXX interface is broken, my program has not moved," the backend will often receive such questioning, but how do we reproduce the problem now? There are several situations:
First, the back end of the test to find no problem
"I tested here is good ah", you can only let the client engineer again, see the error after a certain problem, you have to find the problem, this time this cell phone, and the data inside the phone is very important, because the data can be used to reproduce the Bug.
Second, the test is also a problem
At this time the backend will go to modify the program, but every time the test whether there are problems need to operate in the client, sometimes the operation is very complex, it takes a lot longer. Finally make a variety of Avatar finally found the problem, it is this user's such data has an exception to this situation.
This is not uncommon, the most troublesome point is that each time the same parameters to the occurrence of the Bug to request, sometimes you know the parameters of these requests, you can put them in the Postman tool, but most of the time you do not know its corresponding parameters (token)
If we can track all requests on the server: interface address, header,body, back end of the Header, Body, so that we can find the corresponding request parameters and return value, you can directly fill in the Postman inside, if you can also re-request a key to the good, Because we do not want to modify the parameters of the request, just want to request again with the same parameters, so we can debug the corresponding program.
Just before used Ngrok, found that it has a very good debug interface, can achieve the above requirements, but now do not need its network penetration function, so can only write a program, only contains the following functions:
* Record interface for all Request and Response
* A request can be re-requested with one click
Basic working principle
HTTP client boast Web server | GET http://localhost:8080/| Log requests and Reverse proxy | Response ok| ---------------------------> | --------------------------> | ------┐| | | || | Record return information and forward to client | <----┘| <---------------------------| <--------------------------|┌----------------------------------------------------------------------------┐| url:http://localhost:8081 | | ---------------------------------------------------------------------------|| All transactions┌------------------------┐| | ---------------------- | Time:10 hours ago client:127.0.0.1 | | | | get/200 OK ms | | | || ---------------------- | Request [Replay] | | | | - - - - - - - - - - - - | || | GET http://localhost/HTTP/1.1 | | | | user-agent:curl/7.51.0 | | | | Accept: */* | | | | | || | Response | | | | - - - - - - - - - - - - | || | http/1.1 OK | | | | X-server:httplab | | | | Date:thu, 02:25:27 GMT | | | | content-length:13 | | | | Content-type:text/plain; Charset=utf-8 | | | | | || | HelLo, World | | | └------------------------┘| | |└----------------------------------------------------------------------------┘
Recently learning Go, just take it to complete this small program, named boast in order to allow us to reproduce the Bug more active and convenient, and faster repair, a lot of time to build the wheel!
[Boast project address] (Https://github.com/dcb9/boast)
Go and front-end are now learning to sell, welcome everyone to shoot bricks.
773 reads ∙1 likes