http遵循請求(Request)/應答(Response)模型
- http請求
POST /login.php HTTP/1.1 //請求頭
HOST:www.xxser.com //請求頭
User-Agent:……
//空白行,代表請求頭結束
username=admin&password=admin //請求正文(可不需要) - http響應
HTTP/1.1 200 OK //響應行
Data:… //響應頭
Server:…
//空白行,代表響應頭結束
<html(右括號) //響應正文
……
http請求方法
GET
POST
HEAD
PUT
OPTIONS
注:還有例如WebDAV的通信協議,除上面幾個方法外還添加了一些新方法
可直接對Web Server進行讀寫,並支持文件鎖定和解鎖,文件複製,文件移動,文件版本控制等
- http狀態碼
200
302
404
400
401
403
500
503
http消息
由請求頭、響應頭、普通頭和實體頭組成
- 請求頭
- Host
- User-Agent
- Referer
- Cookie
- Range
- x-forwarded-for
- Accept
- Accept-Charset
- 響應頭
- Server
- Set-Cookie
- Last-Modified
- Location
- Refresh
- 普通頭
- 實體頭
- Content-Type
- Content-Encoding
- Content-Length
- Last-Modified