http请求

1.http请求

request:包括请求行、请求头部、请求数据

response:包括状态行、消息报文、响应正文

样例:

1)

curl -v  http://www.baidu.com >/dev/null

结果为

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:04 --:--:-- 0* About to connect() to www.baidu.com port 80 (#0)
* Trying 61.135.169.125...
0 0 0 0 0 0 0 0 --:--:-- 0:00:05 --:--:-- 0* Connected to www.baidu.com (61.135.169.125) port 80 (#0)
> GET / HTTP/1.1     //get是请求的方法、后面是请求的相关的协议
> User-Agent: curl/7.29.0      //request的head的内容
> Host: www.baidu.com
> Accept: */*
>

 //response的head内容
< HTTP/1.1 200 OK      //200代表相应的状态码
< Server: bfe/1.0.8.18     
< Date: Wed, 11 Oct 2017 07:18:17 GMT
< Content-Type: text/html
< Content-Length: 2381
< Last-Modified: Mon, 23 Jan 2017 13:27:32 GMT
< Connection: Keep-Alive
< ETag: "588604c4-94d"
< Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
< Pragma: no-cache
< Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/
< Accept-Ranges: bytes
<
{ [data not shown]
100 2381 100 2381 0 0 426 0 0:00:05 0:00:05 --:--:-- 586
* Connection #0 to host www.baidu.com left intact

2)如果想看具体返回的内容

curl http://www.baidu.com

原文地址:https://www.cnblogs.com/knyel/p/7650794.html