http请求与响应--之发工资

213 阅读1分钟

我们一般的请求与响应为如下格式

请求与响应

GET 请求 

GET /?w=1 HTTP/1.1
Host: baidu.com
Accept: text/html

响应

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 10000

<!DOCTYPE>
<html>......</html>

POST 请求

POST /login?w=1 HTTP/1.1
Host: baidu.com
Accept: application/ms-word
Content-Type: application/x-www-form-urlencoded
Content-Length: 10

username=fangfang&password=mima

响应

HTTP/1.1 403 Forbidden
Content-Type: application/md-word
Content-Length: 200

word格式

那么类比为发工资的:

Get 请求

GET / HTTP/1.1
host: https://baidu.com
Accept: '现金或者转账'

响应

HTTP/1.1 200 ok
content-type:  现金
content-length : 10 

一般面试的时候会问能不能手写一个get或者post请求,以及一些http状态码是什么意思,把2-5开头的前5个总共20个背下来就可以了。

http状态码

304:304 Not Modified

未改变说明无需再次传输请求的内容,也就是说可以使用缓存的内容。
这通常是在一些安全的方法(safe),例如GET 或HEAD 或在请求中
附带了头部信息: If-None-Match 或If-Modified-Since。