关于HTTP

2019-07-10  本文已影响0人  浪味仙儿啊

HTTP是浏览器与服务器之间传输内容的协议,作用是指导他俩进行沟通。

用curl命令发起请求,示例如下

curl -s -v -H "YU: xxx" -- "https://www.baidu.com"

请求的内容为(包含最下面的空格)

GET / HTTP/1.1
Host: www.baidu.com
User-Agent: curl/7.55.0
Accept: /
YU: xxx

响应的内容为

HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Connection: Keep-Alive
Content-Length: 2443
Content-Type: text/html
Date: Wed, 10 Jul 2019 05:46:42 GMT
Etag: "588603eb-98b"
Last-Modified: Mon, 23 Jan 2017 13:23:55 GMT
Pragma: no-cache
Server: bfe/1.0.8.18
Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/

<!DOCTYPE html>
<html> <head> .......

如curl命令为curl -X POST -s -v -H "YU: xxx" -- "https://www.baidu.com"

请求的内容(包含最下面的空格)

POST / HTTP/1.1
Host: www.baidu.com
User-Agent: curl/7.54.0
Accept: /
YU: xxx

响应的内容

HTTP/1.1 302 Found
Connection: Keep-Alive
Content-Length: 17931
Content-Type: text/html
Date: Tue, 10 Oct 2017 09:19:47 GMT
Etag: "54d9749e-460b"
Server: bfe/1.0.8.18

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"> ……

如curl命令为curl -X POST -d "1234567890" -s -v -H "YU: xxx" -- "https://www.baidu.com"

请求的内容

POST / HTTP/1.1
Host: www.baidu.com
User-Agent: curl/7.54.0
Accept: /
YU: xxx
Content-Length: 10
Content-Type: application/x-www-form-urlencoded

1234567890

用 Chrome 发请求并查看响应

1. ctrl+shift+i

2. 打开network

3. 在地址栏输入网址

②为状态

4. 查看 Requst Headers,点击"view source"即可看到请求内容

5. 查看Response Headers,点击"view source"即可看到响应的前两部分

6.点击Response即可看到响应的第四部分

上一篇 下一篇

猜你喜欢

热点阅读