一. 文件上传,post 提交表单
post 提交数据,遵循一定的格式。
例如当提交如下数据:
pageSize = 1; pageNo = 1
最后http请求体的格式如下:
startBoundary + "\r\n"
Content-Dispsotion: form-data; name = "pageSize"
Context-Type: text/palint
1
startBoundary + "\r\n"
Content-Dispsotion: form-data; name = "pageNo"
Context-Type: text/palint
1
endBoundary
二,文件提交
上传文件本质上和上传其他格式数据没有区别,只是文件是以二进制流的形式被携带。
startBoundary + "\r\n"
Content-Dispsotion: form-data; name = "file"; filename="test.png"
Context-Type: (文件的type)
--文件的内容流
startBoundary + "\r\n"
Content-Dispsotion: form-data; name = "file"; filename="test.png"
Context-Type: (文件的type)