http协议:请求和响应
1.http:请求:
请求行:get/post:
get:请求的参数会显示在地址栏,
post:请求的参数不会显示在地址栏上,
什么时候是post请求呢?
当表单的methed=“post”,才是post请求,其余的是:get请求
请求行:
请求头
请求体:
点击:提交,网络:就会出现
http://localhost:8080/demo16_war/dom2.html?name=1111111111&name=1111111111
再点击这个:就会出现:
请求行,请求头,请求体
这个:分别是:
请求行:
GET /demo16_war/dom2.html?name=1111111111&name=ww%27w%27www HTTP/1.1
请求头:
ccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Connection: keep-alive
Cookie: __guid=111872281.3497693805852452000.1634093114923.0034; monitor_count=7
Host: localhost:8080
Referer: http://localhost:8080/demo16_war/dom1.html
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-origin
Sec-Fetch-User: ?1
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36
请求体:
name=1111111111&name=1111111111(在浏览器网址栏显示,因为是get请求)
效果:
2.http:响应:
响应行:
响应头
响应体
响应行:HTTP/1.1 200
响应头
Accept-Ranges: bytes
ETag: W/"295-1636725734000"
Last-Modified: Fri, 12 Nov 2021 14:02:14 GMT
Content-Type: text/html
Content-Length: 295
Date: Fri, 12 Nov 2021 23:19:21 GMT
Keep-Alive: timeout=20
Connection: keep-alive
响应体:就是浏览器响应时,在网页的代码。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Success!</h1>
</body>
</html>
我的代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>dom1.html</h1>
<form action="dom2.html">
姓名:<input type="text" name="name"/> <br/>
性别:<input type="text" name="name"/> <br/>
<input type="submit" value="提交" >
</form>
</body>
</html>