Skip to content

Commit

Permalink
0831
Browse files Browse the repository at this point in the history
  • Loading branch information
lwstkhyl committed Aug 31, 2024
1 parent c7ad63b commit bb8f3f8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions 01.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
- [文件路径说明](#文件路径说明)
- [案例:批量重命名](#案例批量重命名)
- [path模块](#path模块)
- [http模块](#http模块)
- [HTTP基本概念](#http基本概念)
- [请求](#请求)

<!-- /code_chunk_output -->

Expand Down Expand Up @@ -686,3 +689,24 @@ file_list.forEach(file_name => { //遍历数组
console.log(path.dirname(file_name)); //C:\Users\17185\Desktop\NodeJS
console.log(path.extname(file_name)); //.js
```
### http模块
##### HTTP基本概念
HTTP(hypertext transfer protocol)**超文本传输协议**:对浏览器和服务器间的通信作约束
- **请求**:浏览器向服务器发送数据,发送的内容称为请求报文
- **响应**:服务器给浏览器返回结果,返回的内容称为响应报文

为获取请求与响应的具体内容,这里安装fiddler软件,它可以作为浏览器和服务器间通信的中介,监听请求/响应内容
安装完后,点击`tools`->`options`->`https`->`decrypt https traffic`,之后在弹出的对话框中点击yes;若没有弹出对话框,就点击`action`->`trust root certificate`。最后重启fiddler
![请求1](./md-image/请求1.png){:width=250 height=250}
为更好的监听,建议将下边栏中的`all processes`改为`web browsers`,这样就只监听浏览器中的请求与响应
![请求2](./md-image/请求2.png){:width=250 height=250}
注意:建议使用chrome来进行测试,其它浏览器可能监听不到
双击左侧框中的某条报文,可以在右边框中查看详细信息,其中上面是请求、下面是响应。如果想要看报文原文,点击右侧栏上方的`Raw`(中文版是`数据`)。如果有乱码,就点击`click to decode`
![请求3](./md-image/请求3.png){:width=250 height=250}
###### 请求
**请求报文结构**
- 第一行:请求行
- 第二行~空行:请求头
- 之后的部分:请求体(不一定有)

![请求4](./md-image/请求4.png){:width=300 height=300}
Binary file added md-image/请求1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added md-image/请求2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added md-image/请求3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added md-image/请求4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bb8f3f8

Please sign in to comment.