Skip to content

Commit 461a948

Browse files
committed
http
1 parent d8fca72 commit 461a948

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

Other/http.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# HTTP 请求消息
2+
3+
## 请求行 Request Line:
4+
5+
第一行叫`请求行`,请求行的语法是: `request-method-name request-URI HTTP-version`
6+
7+
request-method-name: http 请求定义了一些请求方法,例如: GET,POST,HEAD,OPTIONS
8+
9+
request-URI:指定请求的资源
10+
11+
HTTP-version:现在有两个版本正在使用: HTTP/1.0 and HTTP/1.1
12+
13+
例如以下都是请求行:
14+
```
15+
GET /test.html HTTP/1.1
16+
HEAD /query.html HTTP/1.0
17+
POST /index.html HTTP/1.1
18+
```
19+
20+
21+
## 请求头 Request Headeers
22+
23+
请求头以`名称:值`的形式出现,可以有多个值,用逗号分割
24+
25+
例如:
26+
```
27+
Host: www.xyz.com
28+
Connection: Keep-Alive
29+
Accept: image/gif, image/jpeg, */*
30+
Accept-Language: us-en, fr, cn
31+
```
32+
33+
# HTTP 响应消息
34+
35+
## 状态行 Status Line
36+
37+
第一行叫`状态行`,状态行的语法是:
38+
`HTTP-version status-code reason-phrase`
39+
40+
HTTP-version: HTTP 版本号
41+
42+
status-code: 3 位数的状态码
43+
44+
reason-phrase: 对状态码的简短解释
45+
46+
例如以下都是状态行:
47+
```
48+
HTTP/1.1 200 OK
49+
HTTP/1.0 404 Not Found
50+
HTTP/1.1 403 Forbidden
51+
```
52+
## 响应头 Reponse Header
53+
54+
与请求头一样,响应头也是以`名称:值`的形式出现,可以有多个值,用逗号分割
55+
56+
以下是例子:
57+
```
58+
Content-Type: text/html
59+
Content-Length: 35
60+
Connection: Keep-Alive
61+
Keep-Alive: timeout=15, max=100
62+
```
63+
64+
# HTTP 请求方法
65+
66+
## GET
67+
68+
GET 是最常见的 HTTP 请求方法,客户端可以使用 GET 请求方法来从 HTTP 服务器请求一些资源
69+
70+
在请求行中大小写敏感,所以必须是大写的 `GET`

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616

1717
## [ Other ]()
1818

19-
[ HTTP ]()
19+
[ HTTP ](./Other/http.md)

0 commit comments

Comments
 (0)