记住 要把localhost替换成本地IP地址
即http://IP地址:端口号/对应的网址或页面 否则charles查看不到电脑发起的请求
查看本地IP地址的方法:在cmd中输入命令行ipconfig或者all然后回车
http请求报文
常见的请求方式
get
post
put
delete
请求报文
请求行
请求方式 请求地址 版本号
请求头
cookie,host,origin,Content-Type
请求体
存储的是发送给服务器的数据
请求头和请求体之间有一个空行,空行的作用是分割请求头和请求体
常见的content-type
application/x-www-form-urlencoded url编码
application/json json格式的
multipart/form-data form-data格式的,通常用来上传文件的时候使用
POST /api/v1/m/ HTTP/1.1
Content-Type: application/json
User-Agent: PostmanRuntime/7.26.1
Accept: */*
Cache-Control: no-cache
Postman-Token: 4a0b429a-8da4-4eac-ad1b-47578714740c
Host: 192.168.17.108:3000
Accept-Encoding: gzip, deflate, br
Content-Length: 45
Connection: keep-alive
{
"name": "王大锤",
"age": 18
}
GET / HTTP/1.1
Host: 192.168.17.108:3000
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
If-None-Match: W/"1f9-iTRx5uJnKb+8uubLIk9+7lRMigs"
Connection: keep-alive
POST /api/v1/m/ HTTP/1.1
User-Agent: PostmanRuntime/7.26.1
Accept: */*
Cache-Control: no-cache
Postman-Token: ef485d1e-1046-497f-940b-5d039df7a580
Host: 192.168.17.108:3000
Accept-Encoding: gzip, deflate, br
Content-Type: application/x-www-form-urlencoded
Content-Length: 99
Connection: keep-alive
name=%E9%93%81%E9%94%A4%E5%A6%B9%E5%A6%B9&age=32&desc=%E5%B2%B3%E5%B2%B3%E7%9A%84%E5%AF%B9%E8%B1%A1
POST /api/v1/m/ HTTP/1.1
User-Agent: PostmanRuntime/7.26.1
Accept: */*
Cache-Control: no-cache
Postman-Token: 94390c7f-e027-4bba-b4b8-1578b20f101c
Host: 192.168.17.108:3000
Accept-Encoding: gzip, deflate, br
Content-Type: multipart/form-data; boundary=--------------------------197118267063313128363709
Content-Length: 279
Connection: keep-alive
----------------------------197118267063313128363709
Content-Disposition: form-data; name="name"
孙越
----------------------------197118267063313128363709
Content-Disposition: form-data; name="skills"
养大象
----------------------------197118267063313128363709--