{"id":1794,"date":"2015-01-18T15:49:14","date_gmt":"2015-01-18T07:49:14","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=1794"},"modified":"2015-01-18T15:49:14","modified_gmt":"2015-01-18T07:49:14","slug":"http%e5%8d%8f%e8%ae%ae%e7%9a%84%e5%88%86%e5%9d%97%e4%bc%a0%e8%be%93%e7%bc%96%e7%a0%81","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/1794.html","title":{"rendered":"HTTP\u534f\u8bae\u7684\u5206\u5757\u4f20\u8f93\u7f16\u7801"},"content":{"rendered":"<p>\u524d\u6bb5\u65f6\u95f4\u5728\u5f04HTTP\u534f\u8bae\u7684\u89e3\u6790\uff0c\u5927\u4f53\u4e0a\u611f\u89c9\u8fd8\u884c\uff0c\u4f46\u662f\u88ab\u4e00\u4e2a\u5730\u65b9\u5361\u4e86\u5f88\u4e45\uff08\u4e4b\u524d\u6ca1\u6709\u7cfb\u7edf\u5b66\u4e60\/\u4e86\u89e3\u8fd9\u65b9\u9762\u7684\u77e5\u8bc6\uff0c\u8fd8\u662f\u6709\u6240\u758f\u6f0f\uff0c\u4e0d\u8fc7\u53ea\u8981\u77e5\u9053\u4e86\u95ee\u9898\u5728\u54ea\uff0c\u5b66\u8d77\u6765\u8fd8\u662f\u5f88\u5feb\u7684~\uff09\uff0c\u540e\u6765\u5728\u9ad8\u624b\u6307\u70b9\u4e0b\uff0c\u4ee5\u53ca\u81ea\u5df1\u4e70\u4e86\u672c\u300aHTTP\u6743\u5a01\u6307\u5357\u300b\u597d\u597d\u770b\u4e86\u770b\uff0c\u8fd8\u662f\u6709\u70b9\u6548\u679c\u7684\uff0c\u8bb0\u5f55\u5982\u4e0b\uff1a<\/p>\n<p>==<\/p>\n<p>\u901a\u5e38\uff0cHTTP\u5e94\u7b54\u6d88\u606f\u4e2d\u53d1\u9001\u7684\u6570\u636e\u662f\u6574\u4e2a\u53d1\u9001\u7684\uff0cContent-Length\u6d88\u606f\u5934\u5b57\u6bb5\u8868\u793a\u6570\u636e\u7684\u957f\u5ea6\u3002<span style=\"color: #ff0000;\">\u6570\u636e\u7684\u957f\u5ea6\u5f88\u91cd\u8981\uff0c\u56e0\u4e3a\u5ba2\u6237\u7aef\u9700\u8981\u77e5\u9053\u54ea\u91cc\u662f\u5e94\u7b54\u6d88\u606f\u7684\u7ed3\u675f\uff0c\u4ee5\u53ca\u540e\u7eed\u5e94\u7b54\u6d88\u606f\u7684\u5f00\u59cb\u3002<\/span>\u7136\u800c\uff0c\u4f7f\u7528\u5206\u5757\u4f20\u8f93\u7f16\u7801\uff0c\u6570\u636e\u5206\u89e3\u6210\u4e00\u7cfb\u5217\u6570\u636e\u5757\uff0c\u5e76\u4ee5\u4e00\u4e2a\u6216\u591a\u4e2a\u5757\u53d1\u9001\uff0c\u8fd9\u6837\u670d\u52a1\u5668\u53ef\u4ee5\u53d1\u9001\u6570\u636e\u800c\u4e0d\u9700\u8981\u9884\u5148\u77e5\u9053\u53d1\u9001\u5185\u5bb9\u7684\u603b\u5927\u5c0f\u3002\u901a\u5e38\u6570\u636e\u5757\u7684\u5927\u5c0f\u662f\u4e00\u81f4\u7684\uff0c\u4f46\u4e5f\u4e0d\u603b\u662f\u8fd9\u79cd\u60c5\u51b5\u3002<\/p>\n<p>Content-Length\u9996\u90e8\u6307\u793a\u51fa\u62a5\u6587\u4e2d\u5b9e\u4f53\u4e3b\u4f53\u7684\u5b57\u8282\u5927\u5c0f\u3002\u8fd9\u4e2a\u5927\u5c0f\u662f\u5305\u542b\u4e86\u6240\u6709\u5185\u5bb9\u7f16\u7801\u7684\uff0c\u6bd4\u5982\uff0c\u5bf9\u6587\u672c\u6587\u4ef6\u8fdb\u884c\u4e86gzip\u538b\u7f29\u7684\u8bdd\uff0c<strong><span style=\"color: #ff0000;\">Content-Length\u9996\u90e8\u5c31\u662f\u538b\u7f29\u540e\u7684\u5927\u5c0f\uff0c\u800c\u4e0d\u662f\u539f\u59cb\u5927\u5c0f<\/span><\/strong>\u3002<\/p>\n<p><span style=\"color: #ff0000;\">\u9664\u975e\u4f7f\u7528\u4e86\u5206\u5757\u7f16\u7801\uff0c\u5426\u5219Content-Length\u9996\u90e8\u5c31\u662f\u5e26\u6709\u5b9e\u4f53\u4e3b\u4f53\u7684\u62a5\u6587\u5fc5\u987b\u4f7f\u7528\u7684\u3002<\/span>\u4f7f\u7528Content-Length\u9996\u90e8\u662f\u4e3a\u4e86\u80fd\u591f\u68c0\u6d4b\u51fa\u670d\u52a1\u5668\u5d29\u6e83\u800c\u5bfc\u81f4\u7684\u62a5\u6587\u622a\u5c3e\uff0c\u5e76\u5bf9\u5171\u4eab\u6301\u4e45\u8fde\u63a5\u7684\u591a\u4e2a\u62a5\u6587\u8fdb\u884c\u6b63\u786e\u5206\u6bb5\u3002<\/p>\n<p>==<\/p>\n<h6>HTTP 1.1\u5f15\u5165\u5206\u5757\u4f20\u8f93\u7f16\u7801\u63d0\u4f9b\u4e86\u4ee5\u4e0b\u51e0\u70b9\u597d\u5904\uff1a<\/h6>\n<ol>\n<li>HTTP\u5206\u5757\u4f20\u8f93\u7f16\u7801\u5141\u8bb8\u670d\u52a1\u5668\u4e3a\u52a8\u6001\u751f\u6210\u7684\u5185\u5bb9\u7ef4\u6301<a href=\"http:\/\/zh.wikipedia.org\/wiki\/HTTP%E6%8C%81%E4%B9%85%E9%93%BE%E6%8E%A5\" target=\"_blank\">HTTP\u6301\u4e45\u94fe\u63a5<\/a>\u3002\u901a\u5e38\uff0c\u6301\u4e45\u94fe\u63a5\u9700\u8981\u670d\u52a1\u5668\u5728\u5f00\u59cb\u53d1\u9001\u6d88\u606f\u4f53\u524d\u53d1\u9001Content-Length\u6d88\u606f\u5934\u5b57\u6bb5\uff0c\u4f46\u662f\u5bf9\u4e8e\u52a8\u6001\u751f\u6210\u7684\u5185\u5bb9\u6765\u8bf4\uff0c\u5728\u5185\u5bb9\u521b\u5efa\u5b8c\u4e4b\u524d\u662f\u4e0d\u53ef\u77e5\u7684\u3002[ <a href=\"http:\/\/tools.ietf.org\/html\/rfc2616#section-3.6.1\" target=\"_blank\">http:\/\/tools.ietf.org\/html\/rfc2616#section-3.6.1<\/a> ]<\/li>\n<li>\u5206\u5757\u4f20\u8f93\u7f16\u7801\u5141\u8bb8\u670d\u52a1\u5668\u5728\u6700\u540e\u53d1\u9001\u6d88\u606f\u5934\u5b57\u6bb5\u3002\u5bf9\u4e8e\u90a3\u4e9b\u5934\u5b57\u6bb5\u503c\u5728\u5185\u5bb9\u88ab\u751f\u6210\u4e4b\u524d\u65e0\u6cd5\u77e5\u9053\u7684\u60c5\u5f62\u975e\u5e38\u91cd\u8981\uff0c\u4f8b\u5982\u6d88\u606f\u7684\u5185\u5bb9\u8981\u4f7f\u7528\u6563\u5217\u8fdb\u884c\u7b7e\u540d\uff0c\u6563\u5217\u7684\u7ed3\u679c\u901a\u8fc7HTTP\u6d88\u606f\u5934\u5b57\u6bb5\u8fdb\u884c\u4f20\u8f93\u3002\u6ca1\u6709\u5206\u5757\u4f20\u8f93\u7f16\u7801\u65f6\uff0c\u670d\u52a1\u5668\u5fc5\u987b\u7f13\u51b2\u5185\u5bb9\u76f4\u5230\u5b8c\u6210\u540e\u8ba1\u7b97\u5934\u5b57\u6bb5\u7684\u503c\u5e76\u5728\u53d1\u9001\u5185\u5bb9\u524d\u53d1\u9001\u8fd9\u4e9b\u5934\u5b57\u6bb5\u7684\u503c\u3002<\/li>\n<li>HTTP\u670d\u52a1\u5668\u6709\u65f6\u4f7f\u7528<a href=\"http:\/\/zh.wikipedia.org\/wiki\/%E6%95%B0%E6%8D%AE%E5%8E%8B%E7%BC%A9\" target=\"_blank\">\u538b\u7f29<\/a>\uff08<a href=\"http:\/\/zh.wikipedia.org\/wiki\/Gzip\" target=\"_blank\">gzip<\/a>\u6216<a href=\"http:\/\/zh.wikipedia.org\/wiki\/DEFLATE\" target=\"_blank\">deflate<\/a>\uff09\u4ee5\u7f29\u77ed\u4f20\u8f93\u82b1\u8d39\u7684\u65f6\u95f4\u3002\u5206\u5757\u4f20\u8f93\u7f16\u7801\u53ef\u4ee5\u7528\u6765\u5206\u9694\u538b\u7f29\u5bf9\u8c61\u7684\u591a\u4e2a\u90e8\u5206\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5757\u4e0d\u662f\u5206\u522b\u538b\u7f29\u7684\uff0c\u800c\u662f\u6574\u4e2a\u8d1f\u8f7d\u8fdb\u884c\u538b\u7f29\uff0c\u538b\u7f29\u7684\u8f93\u51fa\u4f7f\u7528\u672c\u6587\u63cf\u8ff0\u7684\u65b9\u6848\u8fdb\u884c\u5206\u5757\u4f20\u8f93\u3002\u5728\u538b\u7f29\u7684\u60c5\u5f62\u4e2d\uff0c\u5206\u5757\u7f16\u7801\u6709\u5229\u4e8e\u4e00\u8fb9\u8fdb\u884c\u538b\u7f29\u4e00\u8fb9\u53d1\u9001\u6570\u636e\uff0c\u800c\u4e0d\u662f\u5148\u5b8c\u6210\u538b\u7f29\u8fc7\u7a0b\u4ee5\u5f97\u77e5\u538b\u7f29\u540e\u6570\u636e\u7684\u5927\u5c0f\u3002<\/li>\n<\/ol>\n<p>==<\/p>\n<p><a href=\"http:\/\/ixyzero.com\/blog\/wp-content\/uploads\/2015\/01\/chunked_file_encoding.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1795 size-full\" src=\"http:\/\/ixyzero.com\/blog\/wp-content\/uploads\/2015\/01\/chunked_file_encoding.png\" alt=\"chunked_transfer_encoding\" width=\"522\" height=\"599\" \/><\/a><\/p>\n<h6>\u7f16\u7801\u7684\u5e94\u7b54<\/h6>\n<pre class=\"lang:default decode:true\">HTTP\/1.1 200 OK\nContent-Type: text\/plain\nTransfer-Encoding: chunked\n\n25\nThis is the data in the first chunk\n\n1C\nand this is the second one\n\n3\ncon\n8\nsequence\n0\n<\/pre>\n<h6>\u7f16\u7801\u5e94\u7b54\u7684\u89e3\u91ca<\/h6>\n<p>\u524d\u4e24\u4e2a\u5757\u7684\u6570\u636e\u4e2d\u5305\u542b\u6709\u663e\u5f0f\u7684\\r\\n\u5b57\u7b26\u3002<\/p>\n<pre class=\"lang:default decode:true\">\"This is the data in the first chunk\\r\\n\" (37 \u5b57\u7b26 =&gt; \u5341\u516d\u8fdb\u5236: 0x25)\n\"and this is the second one\\r\\n\"          (28 \u5b57\u7b26 =&gt; \u5341\u516d\u8fdb\u5236: 0x1C)\n\"con\"                                     (3  \u5b57\u7b26 =&gt; \u5341\u516d\u8fdb\u5236: 0x03)\n\"sequence\"                                (8  \u5b57\u7b26 =&gt; \u5341\u516d\u8fdb\u5236: 0x08)<\/pre>\n<p><span style=\"color: #ff0000;\"><strong>\u5e94\u7b54\u9700\u8981\u4ee50\u957f\u5ea6\u7684\u5757\uff08\u00a0&#8220;0\\r\\n\\r\\n&#8221;\uff09\u7ed3\u675f<\/strong><\/span>\u3002<\/p>\n<h6>\u89e3\u7801\u7684\u6570\u636e<\/h6>\n<pre class=\"lang:default decode:true\">This is the data in the first chunk\nand this is the second one\nconsequence<\/pre>\n<p>==<\/p>\n<p>HTTP\u534f\u8bae\u4e2d\u786e\u5b9a\u5b9e\u4f53\u4e3b\u4f53\u957f\u5ea6\u7684\u89c4\u5219\uff1a<\/p>\n<ul>\n<li>\u5982\u679c\u7279\u5b9a\u7684HTTP\u62a5\u6587\u7c7b\u578b\u4e2d\u4e0d\u5141\u8bb8\u5e26\u6709\u4e3b\u4f53\uff0c\u5c31\u5ffd\u7565Content-Length\u9996\u90e8\uff0c\u5b83\u662f\u5bf9\u4e3b\u4f53\u8fdb\u884c\u8ba1\u7b97\u7684\uff1b<\/li>\n<li>\u5982\u679c\u62a5\u6587\u4e2d\u542b\u6709\u63cf\u8ff0\u4f20\u8f93\u7f16\u7801\u7684Transfer-Encoding\u9996\u90e8\uff08\u4e0d\u91c7\u7528\u9ed8\u8ba4\u7684HTTP\u201c\u6052\u7b49\u201d\u7f16\u7801\uff09\uff0c\u90a3\u5b9e\u4f53\u5c31\u5e94\u8be5\u7531\u4e00\u4e2a\u79f0\u4e3a\u201c\u96f6\u5b57\u8282\u5757\u201d\uff08zero-byte chunk\uff09\u7684\u7279\u6b8a\u6a21\u5f0f\u7ed3\u675f\uff0c\u9664\u975e\u62a5\u6587\u5df2\u7ecf\u56e0\u8fde\u63a5\u5173\u95ed\u800c\u7ed3\u675f\u3002<\/li>\n<li>\u5982\u679c\u62a5\u6587\u4e2d\u542b\u6709Content-Length\u9996\u90e8\uff08\u5e76\u4e14\u62a5\u6587\u7c7b\u578b\u5141\u8bb8\u6709\u5b9e\u4f53\u4e3b\u4f53\uff09\uff0c\u800c\u4e14\u6ca1\u6709\u975e\u6052\u7b49\u7684Transfer-Encoding\u9996\u90e8\u5b57\u6bb5\uff0c\u90a3\u4e48Content-Length\u7684\u503c\u5c31\u662f\u4e3b\u4f53\u7684\u957f\u5ea6\u3002\u5982\u679c\u6536\u5230\u7684\u62a5\u6587\u4e2d\u65e2\u6709Content-Length\u9996\u90e8\u5b57\u6bb5\u53c8\u6709\u975e\u6052\u7b49\u7684Transfer-Encoding\u9996\u90e8\u5b57\u6bb5\uff0c\u90a3\u5c31\u5fc5\u987b\u5ffd\u7565Content-Length\uff0c\u56e0\u4e3a\u4f20\u8f93\u7f16\u7801\u4f1a\u6539\u53d8\u5b9e\u4f53\u4e3b\u4f53\u7684\u8868\u793a\u548c\u4f20\u8f93\u65b9\u5f0f\uff08\u56e0\u6b64\u53ef\u80fd\u5c31\u4f1a\u6539\u53d8\u4f20\u8f93\u7684\u5b57\u8282\u6570\uff09\u3002<\/li>\n<li>\u5982\u679c\u62a5\u6587\u4f7f\u7528\u4e86multipart\/byteranges\uff08\u591a\u90e8\u5206\/\u5b57\u8282\u8303\u56f4\uff09\u5a92\u4f53\u7c7b\u578b\uff0c\u5e76\u4e14\u6ca1\u6709\u7528Content-Length\u9996\u90e8\u6307\u51fa\u5b9e\u4f53\u4e3b\u4f53\u7684\u957f\u5ea6\uff0c\u90a3\u4e48\u591a\u90e8\u5206\u62a5\u6587\u4e2d\u7684\u6bcf\u4e2a\u90e8\u5206\u90fd\u8981\u8bf4\u660e\u5b83\u81ea\u5df1\u7684\u5927\u5c0f\u3002<\/li>\n<li>\u5982\u679c\u4e0a\u9762\u7684\u89c4\u5219\u90fd\u4e0d\u5339\u914d\uff0c\u5b9e\u4f53\u5c31\u5728\u8fde\u63a5\u5173\u95ed\u7684\u65f6\u5019\u7ed3\u675f\u3002\u5b9e\u9645\u4e0a\uff0c\u53ea\u6709\u670d\u52a1\u5668\u53ef\u4ee5\u4f7f\u7528\u8fde\u63a5\u5173\u95ed\u6765\u6307\u793a\u62a5\u6587\u7684\u7ed3\u675f\u3002\u5ba2\u6237\u7aef\u4e0d\u80fd\u7528\u5173\u95ed\u8fde\u63a5\u6765\u6307\u793a\u5ba2\u6237\u7aef\u62a5\u6587\u7684\u7ed3\u675f\uff0c\u56e0\u4e3a\u8fd9\u6837\u4f1a\u4f7f\u670d\u52a1\u5668\u65e0\u6cd5\u53d1\u56de\u54cd\u5e94\u3002<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h6>\u76f8\u5173\/\u53c2\u8003\u94fe\u63a5\uff1a<\/h6>\n<ul>\n<li><a href=\"http:\/\/ohcoder.com\/blog\/2013\/05\/23\/reading-http-guide\/\" target=\"_blank\">\u8bfb\u300aHTTP\u6743\u5a01\u6307\u5357\u300b\u7b14\u8bb0(\u56db)<\/a><\/li>\n<li><a href=\"http:\/\/blog.csdn.net\/yixian918\/article\/details\/39964709\" target=\"_blank\">Http\u534f\u8bae(3)\u2014HTTP\u5b9e\u4f53\u548c\u7f16\u7801<\/a><\/li>\n<li><a href=\"http:\/\/blog.csdn.net\/xiyue_ruoxi\/article\/details\/40021175\" target=\"_blank\">HTTP\u5b9e\u4f53\u957f\u5ea6\u7684\u786e\u5b9a\u89c4\u5219<\/a><\/li>\n<\/ul>\n<ul>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/19907628\/transfer-encoding-chunked\" target=\"_blank\">http:\/\/stackoverflow.com\/questions\/19907628\/transfer-encoding-chunked<\/a><\/li>\n<\/ul>\n<ul>\n<li><a href=\"http:\/\/www.w3.org\/Protocols\/rfc2616\/rfc2616-sec14.html#sec14.41\" target=\"_blank\">http:\/\/www.w3.org\/Protocols\/rfc2616\/rfc2616-sec14.html#sec14.41<\/a><\/li>\n<\/ul>\n<ul>\n<li><a href=\"http:\/\/en.wikipedia.org\/wiki\/Chunked_transfer_encoding\" target=\"_blank\">http:\/\/en.wikipedia.org\/wiki\/Chunked_transfer_encoding<\/a><\/li>\n<li><a href=\"http:\/\/zh.wikipedia.org\/zh\/%E5%88%86%E5%9D%97%E4%BC%A0%E8%BE%93%E7%BC%96%E7%A0%81\" target=\"_blank\">\u5206\u5757\u4f20\u8f93\u7f16\u7801 &#8211; \u7ef4\u57fa\u767e\u79d1<\/a><\/li>\n<li><a href=\"http:\/\/blog.csdn.net\/yankai0219\/article\/details\/8269922\" target=\"_blank\">\u6587\u7ae05\uff1ahttp\u534f\u8bae\u4e2dcontent-length \u4ee5\u53cachunked\u7f16\u7801\u5206\u6790<\/a><\/li>\n<\/ul>\n<ul>\n<li><a href=\"http:\/\/www.cnblogs.com\/zhaozhan\/archive\/2010\/08\/24\/1807639.html\" target=\"_blank\">HTTP\u534f\u8bae\u7684chunked\u7f16\u7801 &#8211; Asharp<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u6bb5\u65f6\u95f4\u5728\u5f04HTTP\u534f\u8bae\u7684\u89e3\u6790\uff0c\u5927\u4f53\u4e0a\u611f\u89c9\u8fd8\u884c\uff0c\u4f46\u662f\u88ab\u4e00\u4e2a\u5730\u65b9\u5361\u4e86\u5f88\u4e45\uff08\u4e4b\u524d\u6ca1\u6709\u7cfb\u7edf\u5b66\u4e60\/\u4e86\u89e3\u8fd9\u65b9\u9762\u7684\u77e5\u8bc6\uff0c\u8fd8 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[434,22],"class_list":["post-1794","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","tag-chunked","tag-http"],"views":5091,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/1794","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=1794"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/1794\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=1794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=1794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=1794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}