Http post方式传递参数的格式

来源:互联网 发布:2g和4g网络的区别 编辑:程序博客网 时间:2024/05/01 23:44
Head:
Content-Type:multipart/form-data;boundary=(后接一串每个Request body的分割边界,字符串一般由0~9,a~b,A~B,-,_,组成)

Accept-Encoding:(后接客户端识别能识别的服务器发送给来数据的编码格式)

Connection:Keep-Alive(告诉服务器不要关闭连接,由客户端决定什么时候关闭连接)

Cache-Control:no-cache(告诉服务器不要使用缓存)

Content-Length:(后接Request body的大小)

Request body:

“——” + 头部的boundary + “\r\n"
”Content-Disposition: form-data;name=“参数的key”” + “\r\n"
“Content-Type: text/plain; charset=编码格式“ + “\r\n"
”Content-Transfer-Encoding: 8bit“ + “\r\n"
“\r\n"
参数的value
“——” + 头部的boundary + “\r\n"
“Content-Disposition: form-data;name=“参数的key”;filename=“文件名”” + “\r\n"
”Content-Type: application/octet-stream“ + “\r\n"
“Content-Transfer-Encoding: binary” + “\r\n"
“\r\n"
文件的二进制流数据
“——” + 头部的boundary + “——”  + “\r\n”    (这里表示所有的request body的传输完毕
0 0
原创粉丝点击