Skip to content

Commit

Permalink
auto commit
Browse files Browse the repository at this point in the history
  • Loading branch information
CyC2018 committed Nov 2, 2020
1 parent c42ead5 commit 708dc70
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 18 deletions.
77 changes: 68 additions & 9 deletions docs/notes/HTTP.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- GFM-TOC -->
* [基础概念](#-基础概念)
* [URI](#uri)
* [请求和响应报文](#请求和响应报文)
* [URL](#url)
* [HTTP 方法](#二http-方法)
* [GET](#get)
* [HEAD](#head)
Expand Down Expand Up @@ -58,21 +58,78 @@

# 基础概念

## URI
## 请求和响应报文

URI 包含 URL URN
客户端发送一个请求报文给服务器服务器根据请求报文中的信息进行处理并将处理结果放入响应报文中返回给客户端

<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/8441b2c4-dca7-4d6b-8efb-f22efccaf331.png" width="500px"> </div><br>
请求报文结构

## 请求和响应报文
- 第一行是包含了请求方法URL协议版本
- 接下来的多行都是请求首部 Header每个首部都有一个首部名称以及对应的值
- 一个空行用来分隔首部和内容主体 Body
- 最后是请求的内容主体

```
GET http://www.example.com/ HTTP/1.1
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
Cache-Control: max-age=0
Host: www.example.com
If-Modified-Since: Thu, 17 Oct 2019 07:18:26 GMT
If-None-Match: "3147526947+gzip"
Proxy-Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 xxx

param1=1&param2=2
```

响应报文结构

### 1. 请求报文
- 第一行包含协议版本状态码以及描述最常见的是 200 OK 表示请求成功了
- 接下来多行也是首部内容
- 一个空行分隔首部和内容主体
- 最后是响应的内容主体

<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/HTTP_RequestMessageExample.png" width=""/> </div><br>
```
HTTP/1.1 200 OK
Age: 529651
Cache-Control: max-age=604800
Connection: keep-alive
Content-Encoding: gzip
Content-Length: 648
Content-Type: text/html; charset=UTF-8
Date: Mon, 02 Nov 2020 17:53:39 GMT
Etag: "3147526947+ident+gzip"
Expires: Mon, 09 Nov 2020 17:53:39 GMT
Keep-Alive: timeout=4
Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
Proxy-Connection: keep-alive
Server: ECS (sjc/16DF)
Vary: Accept-Encoding
X-Cache: HIT

<!doctype html>
<html>
<head>
<title>Example Domain</title>
// 省略...
</body>
</html>

### 2. 响应报文
```

<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/HTTP_ResponseMessageExample.png" width=""/> </div><br>
## URL

http 使用 URL( **U** niform **R**esource **L**ocator统一资源定位符来定位资源它可以认为是是 URI(**U**niform **R**esource **I**dentifier统一资源标识符的一个子集URL URI 的基础上增加了定位能力URI 除了包含 URL 之外还包含 URNUniform Resource Name统一资源名称),它知识用来定义一个资源的名称并不具备定位该资源的能力例如 urn:isbn:0451450523 用来定义一个书籍但是却没有表示怎么找到这本书

<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/8441b2c4-dca7-4d6b-8efb-f22efccaf331.png" width="500px"> </div><br>

- [wikipedia统一资源标志符](https://zh.wikipedia.org/wiki/统一资源标志符)
- [wikipedia: URL](https://en.wikipedia.org/wiki/URL)
- [rfc26163.2.2 http URL](https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.2.2)
- [What is the difference between a URI, a URL and a URN?](https://stackoverflow.com/questions/176264/what-is-the-difference-between-a-uri-a-url-and-a-urn)

# HTTP 方法

Expand Down Expand Up @@ -171,6 +228,8 @@ CONNECT www.example.com:443 HTTP/1.1

通常不会使用 TRACE并且它容易受到 XST 攻击Cross-Site Tracing跨站追踪)。

- [rfc26169 Method Definitions](https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html)

# HTTP 状态码

服务器返回的 **响应报文** 中第一行为状态行包含了状态码以及原因短语用来告知客户端请求的结果
Expand Down
77 changes: 68 additions & 9 deletions notes/HTTP.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- GFM-TOC -->
* [基础概念](#-基础概念)
* [URI](#uri)
* [请求和响应报文](#请求和响应报文)
* [URL](#url)
* [HTTP 方法](#二http-方法)
* [GET](#get)
* [HEAD](#head)
Expand Down Expand Up @@ -58,21 +58,78 @@

# 基础概念

## URI
## 请求和响应报文

URI 包含 URL URN
客户端发送一个请求报文给服务器服务器根据请求报文中的信息进行处理并将处理结果放入响应报文中返回给客户端

<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/8441b2c4-dca7-4d6b-8efb-f22efccaf331.png" width="500px"> </div><br>
请求报文结构

## 请求和响应报文
- 第一行是包含了请求方法URL协议版本
- 接下来的多行都是请求首部 Header每个首部都有一个首部名称以及对应的值
- 一个空行用来分隔首部和内容主体 Body
- 最后是请求的内容主体

```
GET http://www.example.com/ HTTP/1.1
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
Cache-Control: max-age=0
Host: www.example.com
If-Modified-Since: Thu, 17 Oct 2019 07:18:26 GMT
If-None-Match: "3147526947+gzip"
Proxy-Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 xxx

param1=1&param2=2
```

响应报文结构

### 1. 请求报文
- 第一行包含协议版本状态码以及描述最常见的是 200 OK 表示请求成功了
- 接下来多行也是首部内容
- 一个空行分隔首部和内容主体
- 最后是响应的内容主体

<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/HTTP_RequestMessageExample.png" width=""/> </div><br>
```
HTTP/1.1 200 OK
Age: 529651
Cache-Control: max-age=604800
Connection: keep-alive
Content-Encoding: gzip
Content-Length: 648
Content-Type: text/html; charset=UTF-8
Date: Mon, 02 Nov 2020 17:53:39 GMT
Etag: "3147526947+ident+gzip"
Expires: Mon, 09 Nov 2020 17:53:39 GMT
Keep-Alive: timeout=4
Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
Proxy-Connection: keep-alive
Server: ECS (sjc/16DF)
Vary: Accept-Encoding
X-Cache: HIT

<!doctype html>
<html>
<head>
<title>Example Domain</title>
// 省略...
</body>
</html>

### 2. 响应报文
```

<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/HTTP_ResponseMessageExample.png" width=""/> </div><br>
## URL

http 使用 URL( **U** niform **R**esource **L**ocator统一资源定位符来定位资源它可以认为是是 URI(**U**niform **R**esource **I**dentifier统一资源标识符的一个子集URL URI 的基础上增加了定位能力URI 除了包含 URL 之外还包含 URNUniform Resource Name统一资源名称),它知识用来定义一个资源的名称并不具备定位该资源的能力例如 urn:isbn:0451450523 用来定义一个书籍但是却没有表示怎么找到这本书

<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/8441b2c4-dca7-4d6b-8efb-f22efccaf331.png" width="500px"> </div><br>

- [wikipedia统一资源标志符](https://zh.wikipedia.org/wiki/统一资源标志符)
- [wikipedia: URL](https://en.wikipedia.org/wiki/URL)
- [rfc26163.2.2 http URL](https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.2.2)
- [What is the difference between a URI, a URL and a URN?](https://stackoverflow.com/questions/176264/what-is-the-difference-between-a-uri-a-url-and-a-urn)

# HTTP 方法

Expand Down Expand Up @@ -171,6 +228,8 @@ CONNECT www.example.com:443 HTTP/1.1

通常不会使用 TRACE并且它容易受到 XST 攻击Cross-Site Tracing跨站追踪)。

- [rfc26169 Method Definitions](https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html)

# HTTP 状态码

服务器返回的 **响应报文** 中第一行为状态行包含了状态码以及原因短语用来告知客户端请求的结果
Expand Down
Binary file added notes/pics/image-20201103021112251.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 708dc70

Please sign in to comment.