Linux get and post request (curl or wget) simulating http detail
- 2020-06-03 09:07:21
- OfStack
Linux simulation http get/post request (curl or wget) detail
background
Recently, the test interface is needed in the project, but the test server can only be accessed through the fortress machine. For the time being, it has not been forwarded through Nginx, so it has to simulate http request directly on Linux for testing.
methods
get request
curl http: / / www. baidu. com "if URL pointing to a file or a picture can be directly downloaded to the local
curl - i "http: / / www. baidu. com" show all information
curl - l "http: / / www. baidu. com" show only the header information
curl - v "http: / / www. baidu. com" whole process show get request parsing
wget http: / / www. baidu. com"
post request
curl - d "param1 = value1
&
param2 = value2 "" http: / / www. baidu. com"
With the -ES79en parameter, put the access parameter inside. If there is no parameter, -ES80en is not needed.
wget � post - data 'user = foo & password=bar' http://www.baidu.com
curl and wget
In practice, curl emulates access request 1 to display directly in the console, while wget saves the result as a file. If the results are small and you need to see the results directly, consider using curl for the mock request, or wget for the mock request if the results are large.
Thank you for reading, I hope to help you, thank you for your support to this site!