{"id":672,"date":"2023-01-16T20:34:48","date_gmt":"2023-01-16T12:34:48","guid":{"rendered":"http:\/\/blog.nonot.cn\/?p=672"},"modified":"2023-01-16T20:34:48","modified_gmt":"2023-01-16T12:34:48","slug":"%e5%9b%be%e7%89%87%e5%90%8e%e7%bc%80%e5%92%8ccontenttype%e5%a4%a7%e5%85%a8","status":"publish","type":"post","link":"https:\/\/blog.nonot.cn\/index.php\/2023\/01\/16\/%e5%9b%be%e7%89%87%e5%90%8e%e7%bc%80%e5%92%8ccontenttype%e5%a4%a7%e5%85%a8\/","title":{"rendered":"Content-type\u7684\u51e0\u79cd\u5e38\u89c1\u7c7b\u578b"},"content":{"rendered":"<h5>1\u3001application\/x-www-form-urlencoded<\/h5>\n<p>1\uff09\u6d4f\u89c8\u5668\u7684\u539f\u751fform\u8868\u5355<br \/>\n2\uff09\u63d0\u4ea4\u7684\u6570\u636e\u6309\u7167 key1=val1&amp;key2=val2 \u7684\u65b9\u5f0f\u8fdb\u884c\u7f16\u7801\uff0ckey\u548cval\u90fd\u8fdb\u884c\u4e86URL\u8f6c\u7801<\/p>\n<div class=\"cnblogs_code\">\n<pre>POST [http:\/\/www.example.com](http:\/\/www.example.com) HTTP\/1.1 \nContent-Type: application\/x-[www-form-urlencoded](http:\/\/www-form-urlencoded);charset=utf-8 \n\ntitle=test&amp;sub%5B%5D=1&amp;sub%5B%5D=2&amp;sub%5B%5D=3<\/pre>\n<\/div>\n<h5>2\u3001multipart\/form-data<\/h5>\n<p>\u5e38\u89c1\u7684 POST \u6570\u636e\u63d0\u4ea4\u7684\u65b9\u5f0f\u3002\u6211\u4eec\u4f7f\u7528\u8868\u5355\u4e0a\u4f20\u6587\u4ef6\u65f6\uff0c\u5fc5\u987b\u8ba9 form \u7684 enctype \u7b49\u4e8e\u8fd9\u4e2a\u503c\u3002<\/p>\n<div class=\"cnblogs_code\">\n<pre>&lt;form action=\"\/\" method=\"post\" enctype=\"multipart\/form-data\"&gt;\n  &lt;input type=\"text\" name=\"description\" value=\"some text\"&gt;\n  &lt;input type=\"file\" name=\"myFile\"&gt;\n  &lt;button type=\"submit\"&gt;Submit&lt;\/button&gt;\n&lt;\/form&gt;<\/pre>\n<\/div>\n<p>\u8bf7\u6c42\u5934\u770b\u8d77\u6765\u50cf\u8fd9\u6837<\/p>\n<div class=\"cnblogs_code\">\n<pre class=\"\">POST \/foo HTTP\/1.1\nContent-Length: 68137\nContent-Type: multipart\/form-data; boundary=---------------------------974767299852498929531610575\n\n---------------------------974767299852498929531610575\nContent-Disposition: form-data; name=\"description\"\n\nsome text\n---------------------------974767299852498929531610575\nContent-Disposition: form-data; name=\"myFile\"; filename=\"foo.txt\"\nContent-Type: text\/plain\n\n(content of the uploaded file foo.txt)\n---------------------------974767299852498929531610575--<\/pre>\n<\/div>\n<h5>3\u3001application\/json<\/h5>\n<p>\u6d88\u606f\u4e3b\u4f53\u662f\u5e8f\u5217\u5316\u540e\u7684 JSON \u5b57\u7b26\u4e32,\u8fd9\u4e2a\u7c7b\u578b\u8d8a\u6765\u8d8a\u591a\u5730\u88ab\u5927\u5bb6\u6240\u4f7f\u7528<\/p>\n<div class=\"cnblogs_code\">\n<pre>POST [http:\/\/www.example.com](http:\/\/www.example.com) HTTP\/1.1 \nContent-Type: application\/json;charset=utf-8 \n\n{\"title\":\"test\",\"sub\":[1,2,3]}<\/pre>\n<\/div>\n<h5>4\u3001text\/xml<\/h5>\n<p>\u662f\u4e00\u79cd\u4f7f\u7528 HTTP \u4f5c\u4e3a\u4f20\u8f93\u534f\u8bae\uff0cXML \u4f5c\u4e3a\u7f16\u7801\u65b9\u5f0f\u7684\u8fdc\u7a0b\u8c03\u7528\u89c4\u8303<\/p>\n<div class=\"cnblogs_code\">\n<pre class=\"\">POST [http:\/\/www.example.com](http:\/\/www.example.com) HTTP\/1.1 \nContent-Type: text\/xml \n&lt;!--?xml version=\"1.0\"?--&gt; \n&lt;methodcall&gt; \n    &lt;methodname&gt;examples.getStateName&lt;\/methodname&gt; \n    &lt;params&gt; \n        &lt;param&gt; \n            &lt;value&gt;&lt;i4&gt;41&lt;\/i4&gt;&lt;\/value&gt; \n    &lt;\/params&gt; \n&lt;\/methodcall&gt;<\/pre>\n<\/div>\n<p>5.\u5176\u4ed6<\/p>\n<div class=\"cnblogs_code\">\n<pre class=\"\">text\/html  \uff1aHTML\u683c\u5f0f\ntext\/plain \uff1a\u7eaf\u6587\u672c\u683c\u5f0f      \ntext\/xml   \uff1aXML\u683c\u5f0f\n\nimage\/gif  \uff1agif\u56fe\u7247\u683c\u5f0f    \nimage\/jpeg \uff1ajpg\u56fe\u7247\u683c\u5f0f \nimage\/png  \uff1apng\u56fe\u7247\u683c\u5f0f\n\napplication\/xml     \uff1a XML\u6570\u636e\u683c\u5f0f\napplication\/json    \uff1a JSON\u6570\u636e\u683c\u5f0f\napplication\/pdf     \uff1a pdf\u683c\u5f0f  \napplication\/msword  \uff1a Word\u6587\u6863\u683c\u5f0f\napplication\/octet-stream \uff1a \u4e8c\u8fdb\u5236\u6d41\u6570\u636e\uff08\u5982\u6587\u4ef6\u4e0b\u8f7d\uff09\n\napplication\/x-www-form-urlencoded \uff1a \n\n&lt;form encType=\"\"&gt;\u4e2d\u9ed8\u8ba4\u7684encType\uff0c\nform\u8868\u5355\u6570\u636e\u88ab\u7f16\u7801\u4e3akey\/value\u683c\u5f0f\u53d1\u9001\u5230\u670d\u52a1\u5668\uff08\u8868\u5355\u9ed8\u8ba4\u7684\u63d0\u4ea4\u6570\u636e\u7684\u683c\u5f0f\uff09\u3002\n\u670d\u52a1\u5668\u6536\u5230\u7684raw body\u4f1a\u662f\uff0cname=aaa&amp;key=bbb\u3002\n\nmultipart\/form-data \uff1a \u8868\u5355\u4e0a\u4f20\u6587\u4ef6<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001application\/x-www-form-urlen&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-672","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/672","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/comments?post=672"}],"version-history":[{"count":0,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/672\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/media?parent=672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/categories?post=672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/tags?post=672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}