A simple GET request
to use curl command can easily initiate an HTTP request:
# 使用GET凡是请求网址
curl http://www.baidu.com
You can use the -X option specifies the request methods
carry the parameters of the POST request to
the following presentation consists of a head and parameters of a POST request
curl -X POST \
'http://uusama.com/?r=SnapchatApi%2FdoCurlQuery' \
-H 'cache-control: no-cache' \
-H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
-F name=uusama \
-F like=fruit
This embodiment corresponds to the request to submit a form in the page, wherein:
POST request usually specifies the -X-POST request is
-H designation request header
-F request parameter specified
Processed test request command curl
in the curl command, there are several variables request time the reaction:
time_namelookup: DNS to resolve domain names time, the domain -> ipd time
time_connect: TCP connection, the three-way handshake time
time_appconnect: SSL | time SSH and other upper layer connection established
time_pretransfer: request from the beginning to the time response start transmission of
time_redirect: time from beginning to end a transaction request
time_starttransfer: start request from the first byte to be transmitted time
TIME_TOTAL: total time
example:
curl -o /dev/null -s -w time_namelookup:"\t"%{time_namelookup}"\n"time_connect:"\t\t"%{time_connect}"\n"time_appconnect:"\t"%{time_appconnect}"\n"time_pretransfer:"\t"%{time_pretransfer}"\n"time_starttransfer:"\t"%{time_starttransfer}"\n"time_total:"\t\t"%{time_total}"\n"time_redirect:"\t\t"%{time_redirect}"\n" http://www.baidu.com
time_namelookup: 5.520
time_connect: 5.543
time_appconnect: 0.000
time_pretransfer: 5.543
time_starttransfer: 5.566
time_total: 5.566
time_redirect: 0.000
The meaning of each option are as follows:
-w: The request result to file instead of standard output
-o: Use custom format output request is completed
-s: silent mode (do not output anything)