We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP POST 方法可以向服务器发送数据。请求体的类型取决于Content-Type头。
POST
Content-Type
POST与PUT不同的地方有以下几个方面:
<form>标签
<input>``<button>
application/x-www-form-urlencoded
=
&
multipart/form-data
Content-Disposition
由叫URL编码,将8bit的非数字非字母字符编码为%{X}X为十进制的ASCII值。 注意%本身也需要编码,编为%25。
%{X}
// req headers Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryRhKAYVI9DWMVtI2t
body可以是任意类型,根据HTTP1.1的定义,支持一下的方法
POST /test
application/x-www.form-urlencoded
POST /test HTTP/1.1 Host: foo.example Content-Type: application/x-www-form-urlencoded Content-Length: 27 field1=value1&field2=value2
POST /test HTTP/1.1 Host: foo.example Content-Type: multipart/form-data;boundary="boundary" --boundary Content-Disposition: form-data; name="field1" value1 --boundary Content-Disposition: form-data; name="field2"; filename="example.txt" value2 --boundary--
《Hi gays, 你造Content-Disposition吗?》
通过设置Content-Type:application/json;charset=UTF-8传输JSON。
Content-Type:application/json;charset=UTF-8
Request Method: Post Content-Type: application/json;charset=UTF-8 Request Payload: {"mpAlias":"foobarbaz", "pageIndex": "1", "pageSize": "10"}
参考资料: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
The text was updated successfully, but these errors were encountered:
No branches or pull requests
POST只能发送一种类型的请求体吗?
HTTP
POST
方法可以向服务器发送数据。请求体的类型取决于Content-Type
头。POST与PUT有什么不同?
POST与PUT不同的地方有以下几个方面:
可以通过哪些方式发送POST请求?
<form>标签
的enctype属性和<input>``<button>
标签的formenctype属性去指定内容的MIME类型POST常见的MIME类型有哪些?
application/x-www-form-urlencoded
: 键值由=
连接,键值之间通过&
分割。非字母或数字的字符会被 百分比编码: 这也就是为什么这种类型不支持二进制数据(应使用 multipart/form-data 代替).multipart/form-data
: 每个值会被当做一个数据块发送(body part),通过User Agent定义的分隔符分割键值。键来自于各个部分的Content-Disposition
头。什么是百分比编码?
由叫URL编码,将8bit的非数字非字母字符编码为
%{X}
X为十进制的ASCII值。注意%本身也需要编码,编为%25。
项目中的multipart/form-data请求
不通过form表单,通过XHR发送的话,POST如何表现?
body可以是任意类型,根据HTTP1.1的定义,支持一下的方法
POST基本信息
POST语法
application/x-www.form-urlencoded
请求和multipart/form-data
请求例子application/x-www.form-urlencoded
multipart/form-data
如何更加详细的理解Content-Disposition
《Hi gays, 你造Content-Disposition吗?》
实际项目中用到的最多的POST是哪一种?
通过设置
Content-Type:application/json;charset=UTF-8
传输JSON。参考资料: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
The text was updated successfully, but these errors were encountered: