{"id":43397,"date":"2025-06-12T13:55:57","date_gmt":"2025-06-12T05:55:57","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/43397.html"},"modified":"2025-06-12T13:55:57","modified_gmt":"2025-06-12T05:55:57","slug":"k230-%e8%bf%90%e8%a1%8c-http-%e6%9c%8d%e5%8a%a1%e5%99%a8-httpserver","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/43397.html","title":{"rendered":"K230 \u8fd0\u884c HTTP \u670d\u52a1\u5668 httpserver"},"content":{"rendered":"<h2>HTTP-Server\u4f8b\u7a0b<\/h2>\n<\/p>\n<h4>\u6587\u7ae0\u76ee\u5f55<\/h4>\n<ul>\n<li>HTTP-Server\u4f8b\u7a0b<\/li>\n<li>\n<ul>\n<li>\u5b9e\u9a8c\u73af\u5883<\/li>\n<li>\u7b80\u4ecb<\/li>\n<li>\u5173\u952e\u90e8\u5206\u4ee3\u7801<\/li>\n<li>\u6d41\u7a0b\u56fe<\/li>\n<li>HTTP \u670d\u52a1\u7aef<\/li>\n<li>\n<ul>\n<li>HTTP \u8bf7\u6c42<\/li>\n<li>HTML \u9875\u9762<\/li>\n<li>HTTP \u72b6\u6001\u7801<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>\u5b9e\u9a8c\u73af\u5883<\/h3>\n<p>\u4e9a\u535a\u667a\u80fd K230 \u89c6\u89c9\u8bc6\u522b\u6a21\u5757 \u56fa\u4ef6\u7248\u672c&#xff1a;CanMV_K230_YAHBOOM_micropython_V1.3.2.img.gz<\/p>\n<p>\u6ce81&#xff1a;\u7528\u5176\u5b83\u5382\u5bb6\u7684K230\u4e5f\u53ef\u4ee5\u5b9e\u73b0&#xff0c;\u53ea\u662f\u4ee3\u7801\u90e8\u5206\u9700\u8981\u7a0d\u4f5c\u4fee\u6539&#xff0c;\u4ee3\u7801\u90e8\u5206\u4e9a\u535aK230\u7528\u7684\u5c4f\u5e55\u5206\u8fa8\u7387\u662f640&#215;480 \u6ce82&#xff1a;\u672c\u6587\u6458\u81ea\u4e9a\u535a\u5b98\u7f51K230\u7cfb\u5217\u7684\u6559\u7a0b&#xff0c;\u6b64\u5904\u4ec5\u4f5c\u5206\u4eab\u4f5c\u7528<\/p>\n<h3>\u7b80\u4ecb<\/h3>\n<p>\u672c\u8282\u6211\u4eec\u4f7f\u7528K230\u4f5c\u4e3aHTTP\u670d\u52a1\u5668\u4f7f\u7528\u3002<\/p>\n<p>\u6211\u4eec\u6253\u5f00\u4f8b\u7a0b\u4ee3\u7801&#xff0c;\u4fee\u6539main\u51fd\u6570\u4e2d\u7684Connect_WIFI\u51fd\u6570\u7684\u53c2\u6570\u4e3aSSID&#xff08;WIFI\u7684\u540d\u79f0&#xff09;\u548cKEY&#xff08;WIFI\u7684\u5bc6\u7801&#xff09;<\/p>\n<p>ip <span class=\"token operator\">&#061;<\/span> Connect_WIFI<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;[SSID]&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;[KEY]&#034;<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u4fee\u6539\u597d\u4e4b\u540e\u6211\u4eec\u70b9\u51fb\u8fd0\u884c\u6309\u94ae&#xff0c;\u53ef\u4ee5\u770b\u5230\u4e32\u884c\u4e2d\u65ad\u8f93\u51fa\u5982\u4e0b\u5185\u5bb9<\/p>\n<p>True<br \/>\n(&#039;192.168.3.47&#039;, &#039;255.255.255.0&#039;, &#039;192.168.3.1&#039;, &#039;192.168.3.1&#039;)<br \/>\nListening, connect your browser to http:\/\/192.168.3.47:8081\/<\/p>\n<p>\u7b2c\u4e00\u884c\u7684True\u8868\u793aWIFI\u8fde\u63a5\u6210\u529f<\/p>\n<p>\u7b2c\u4e8c\u884c\u8f93\u51fa\u7684\u662f\u8fde\u63a5\u7684WIFI\u7684\u4fe1\u606f<\/p>\n<p>\u7b2c\u4e09\u884c\u8868\u793aHTTP\u670d\u52a1\u5668\u542f\u52a8\u6210\u529f\u4e86&#xff0c;\u6211\u4eec\u53ef\u4ee5\u590d\u5236\u8fd9\u4e2a\u5730\u5740&#xff0c;\u7c98\u8d34\u5230\u6d4f\u89c8\u5668\u7684\u5730\u5740\u680f&#xff0c;\u6309\u4e0b\u56de\u8f66\u952e<\/p>\n<p>\u53ef\u4ee5\u770b\u5230\u6d4f\u89c8\u5668\u4e2d\u663e\u793a\u8fd9\u4e2a\u9875\u9762&#xff0c;\u5219\u8bf4\u660e\u542f\u52a8\u6210\u529f\u4e86<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250612055553-684a6be9e36c7.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>\u5173\u952e\u90e8\u5206\u4ee3\u7801<\/h3>\n<p>\u5b8c\u6574\u4ee3\u7801\u8bf7\u53c2\u8003 \u3010\u6e90\u7801\u6c47\u603b \/ 11.Network \/ 05.http \/ http_server.py\u3011<\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span>micropython_optimize<span class=\"token operator\">&#061;<\/span><span class=\"token boolean\">True<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token comment\"># \u8fde\u63a5WiFi\u5e76\u83b7\u53d6IP Connect to WiFi and get IP<\/span><br \/>\n    ip <span class=\"token operator\">&#061;<\/span> Connect_WIFI<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Yahboom&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;my_password&#034;<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>    <span class=\"token comment\"># \u521b\u5efasocket\u5bf9\u8c61 Create socket object<\/span><br \/>\n    s <span class=\"token operator\">&#061;<\/span> socket<span class=\"token punctuation\">.<\/span>socket<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token comment\"># \u83b7\u53d6\u5730\u5740\u4fe1\u606f Get address information<\/span><br \/>\n    ai <span class=\"token operator\">&#061;<\/span> socket<span class=\"token punctuation\">.<\/span>getaddrinfo<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;0.0.0.0&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">8081<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    addr <span class=\"token operator\">&#061;<\/span> ai<span class=\"token punctuation\">[<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">[<\/span><span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">]<\/span><br \/>\n    <span class=\"token comment\"># \u8bbe\u7f6esocket\u9009\u9879 Set socket options<\/span><br \/>\n    s<span class=\"token punctuation\">.<\/span>setsockopt<span class=\"token punctuation\">(<\/span>socket<span class=\"token punctuation\">.<\/span>SOL_SOCKET<span class=\"token punctuation\">,<\/span> socket<span class=\"token punctuation\">.<\/span>SO_REUSEADDR<span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token comment\"># \u7ed1\u5b9a\u5730\u5740 Bind address<\/span><br \/>\n    s<span class=\"token punctuation\">.<\/span>bind<span class=\"token punctuation\">(<\/span>addr<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token comment\"># \u5f00\u59cb\u76d1\u542c Start listening<\/span><br \/>\n    s<span class=\"token punctuation\">.<\/span>listen<span class=\"token punctuation\">(<\/span><span class=\"token number\">5<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Listening, connect your browser to http:\/\/%s:8081\/&#034;<\/span> <span class=\"token operator\">%<\/span> <span class=\"token punctuation\">(<\/span>ip<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>    counter <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><br \/>\n    <span class=\"token comment\"># \u4e3b\u5faa\u73af\u5904\u7406\u5ba2\u6237\u7aef\u8fde\u63a5 Main loop to handle client connections<\/span><br \/>\n    <span class=\"token keyword\">while<\/span> <span class=\"token boolean\">True<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token comment\"># \u63a5\u53d7\u5ba2\u6237\u7aef\u8fde\u63a5 Accept client connection<\/span><br \/>\n        res <span class=\"token operator\">&#061;<\/span> s<span class=\"token punctuation\">.<\/span>accept<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        client_sock <span class=\"token operator\">&#061;<\/span> res<span class=\"token punctuation\">[<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">]<\/span><br \/>\n        client_addr <span class=\"token operator\">&#061;<\/span> res<span class=\"token punctuation\">[<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">]<\/span><br \/>\n        <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Client address:&#034;<\/span><span class=\"token punctuation\">,<\/span> client_addr<span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token comment\"># \u8bbe\u7f6e\u975e\u963b\u585e\u6a21\u5f0f Set non-blocking mode<\/span><br \/>\n        client_sock<span class=\"token punctuation\">.<\/span>setblocking<span class=\"token punctuation\">(<\/span><span class=\"token boolean\">False<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token comment\"># \u83b7\u53d6\u5ba2\u6237\u7aef\u6d41 Get client stream<\/span><br \/>\n        client_stream <span class=\"token operator\">&#061;<\/span> client_sock <span class=\"token keyword\">if<\/span> micropython_optimize <span class=\"token keyword\">else<\/span> client_sock<span class=\"token punctuation\">.<\/span>makefile<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;rwb&#034;<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>        <span class=\"token comment\"># \u8bfb\u53d6HTTP\u8bf7\u6c42\u5934 Read HTTP request headers<\/span><br \/>\n        <span class=\"token keyword\">while<\/span> <span class=\"token boolean\">True<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            h <span class=\"token operator\">&#061;<\/span> client_stream<span class=\"token punctuation\">.<\/span>read<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n            <span class=\"token keyword\">if<\/span> h <span class=\"token keyword\">is<\/span> <span class=\"token boolean\">None<\/span> <span class=\"token keyword\">or<\/span> h<span class=\"token operator\">&#061;&#061;<\/span><span class=\"token string\">b&#039;&#039;<\/span><span class=\"token punctuation\">:<\/span><br \/>\n                <span class=\"token keyword\">continue<\/span><br \/>\n            <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>h<span class=\"token punctuation\">)<\/span><br \/>\n            <span class=\"token keyword\">if<\/span> h<span class=\"token punctuation\">.<\/span>endswith<span class=\"token punctuation\">(<\/span><span class=\"token string\">b&#039;\\\\r\\\\n\\\\r\\\\n&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n                <span class=\"token keyword\">break<\/span><br \/>\n            os<span class=\"token punctuation\">.<\/span>exitpoint<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>        <span class=\"token comment\"># \u53d1\u9001\u54cd\u5e94\u5185\u5bb9 Send response content<\/span><br \/>\n        client_stream<span class=\"token punctuation\">.<\/span>write<span class=\"token punctuation\">(<\/span>CONTENT<span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token comment\"># \u5173\u95ed\u5ba2\u6237\u7aef\u8fde\u63a5 Close client connection<\/span><br \/>\n        client_stream<span class=\"token punctuation\">.<\/span>close<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># \u8fd0\u884c\u4e3b\u51fd\u6570 Run main function<\/span><br \/>\nmain<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u5176\u4e2dCONTENT\u90e8\u5206\u662f\u6211\u4eec\u6d4f\u89c8\u5668\u4e2d\u663e\u793a\u7684\u9875\u9762\u4ee3\u7801&#xff0c;\u4f7f\u7528\u7684\u662fHTML\u8bed\u8a00<\/p>\n<p><span class=\"token doctype\"><span class=\"token punctuation\">&lt;!<\/span><span class=\"token doctype-tag\">DOCTYPE<\/span> <span class=\"token name\">html<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>html<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>head<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>meta<\/span> <span class=\"token attr-name\">charset<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span>utf-8<span class=\"token punctuation\">&#034;<\/span><\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>title<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>\u4e9a\u535a\u667a\u80fdK230<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>title<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>style<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><span class=\"token style\"><span class=\"token language-css\"><br \/>\n            <span class=\"token selector\">body<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                <span class=\"token property\">font-family<\/span><span class=\"token punctuation\">:<\/span> Arial<span class=\"token punctuation\">,<\/span> sans-serif<span class=\"token punctuation\">;<\/span><br \/>\n                <span class=\"token property\">margin<\/span><span class=\"token punctuation\">:<\/span> 0<span class=\"token punctuation\">;<\/span><br \/>\n                <span class=\"token property\">padding<\/span><span class=\"token punctuation\">:<\/span> 20px<span class=\"token punctuation\">;<\/span><br \/>\n                <span class=\"token property\">background-color<\/span><span class=\"token punctuation\">:<\/span> #f0f0f0<span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token punctuation\">}<\/span><br \/>\n            <span class=\"token selector\">h1<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                <span class=\"token property\">color<\/span><span class=\"token punctuation\">:<\/span> #333<span class=\"token punctuation\">;<\/span><br \/>\n                <span class=\"token property\">text-align<\/span><span class=\"token punctuation\">:<\/span> center<span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token punctuation\">}<\/span><br \/>\n            <span class=\"token selector\">h2<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                <span class=\"token property\">color<\/span><span class=\"token punctuation\">:<\/span> #222<span class=\"token punctuation\">;<\/span><br \/>\n                <span class=\"token property\">text-align<\/span><span class=\"token punctuation\">:<\/span> center<span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token punctuation\">}<\/span><br \/>\n        <\/span><\/span><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>style<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>head<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>body<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>h1<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>\u6b22\u8fce\u4f7f\u7528\u4e9a\u535a\u667a\u80fd K230<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>h1<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>h2<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>Welcome to yahboom K230<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>h2<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>body<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>html<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><\/p>\n<h3>\u6d41\u7a0b\u56fe<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250612055554-684a6bea44efa.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>HTTP \u670d\u52a1\u7aef<\/h3>\n<p>\u8fd9\u91cc\u6211\u4eec\u6765\u7b80\u5355\u63cf\u8ff0\u4e00\u4e0bHTTP\u670d\u52a1\u7aef<\/p>\n<h4>HTTP \u8bf7\u6c42<\/h4>\n<p>HTTP(\u8d85\u6587\u672c\u4f20\u8f93\u534f\u8bae)\u662f\u4e00\u4e2a\u7528\u4e8e\u5728\u7f51\u7edc\u4e0a\u4f20\u8f93\u6570\u636e\u7684\u5e94\u7528\u5c42\u534f\u8bae\u3002<\/p>\n<p>\u6211\u4eec\u5e73\u65f6\u4f7f\u7528\u6d4f\u89c8\u5668\u8bbf\u95ee\u7f51\u9875&#xff0c;\u6211\u4eec\u5728\u7f51\u9875\u4e0a\u8fdb\u884c\u7684\u70b9\u51fb\u6216\u8005\u4efb\u4f55\u64cd\u4f5c&#xff0c;\u5b9e\u9645\u4e0a\u5c31\u662f\u901a\u8fc7\u6d4f\u89c8\u5668\u5411HTTP\u670d\u52a1\u5668\u53d1\u9001\u8bf7\u6c42&#xff0c;\u7136\u540eHTTP\u670d\u52a1\u5668\u8fd4\u56de\u6570\u636e&#xff08;\u6570\u636e\u53ef\u4ee5\u662f\u56fe\u7247\u3001\u89c6\u9891\u3001\u6216\u8005HTML\u9875\u9762\u7b49\u4efb\u4f55\u7c7b\u578b\u7684\u6570\u636e&#xff0c;\u5177\u4f53\u8fd4\u56de\u4ec0\u4e48\u662f\u6839\u636e\u4f60\u8bf7\u6c42\u7684\u64cd\u4f5c\u51b3\u5b9a\u7684&#xff09;\u3002\u6211\u4eec\u672c\u8282\u6559\u7a0b\u5b9e\u73b0\u7684 HTTP\u670d\u52a1\u5668\u505a\u7684\u4e8b\u60c5\u5c31\u662f \u63a5\u6536http\u8bf7\u6c42&#xff0c;\u8fd4\u56de\u4e00\u4e2aHTML\u9875\u9762\u6570\u636e\u3002<\/p>\n<h4>HTML \u9875\u9762<\/h4>\n<p>HTML\u9875\u9762\u662f\u4e00\u79cd\u53ef\u4ee5\u88ab\u6d4f\u89c8\u5668\u8bc6\u522b\u5e76\u89e3\u6790\u7684\u63cf\u8ff0\u6587\u4ef6\u3002\u53ef\u4ee5\u7b80\u5355\u7406\u89e3\u4e3a\u6211\u4eec\u5e73\u65f6\u770b\u5230\u7684\u7f51\u9875\u5c31\u662f\u7531HTML\u8bed\u8a00\u7f16\u5199\u7684\u3002\u672c\u8282\u6559\u7a0b\u4e2d\u6211\u4eec\u7684CONTENT\u53d8\u91cf\u4e2d\u7684\u5185\u5bb9\u5c31\u662f\u4e00\u4e2a\u7b80\u5355\u7684HTML\u4ee3\u7801\u3002\u5f53\u6d4f\u89c8\u5668\u63a5\u6536\u5230HTTP\u670d\u52a1\u5668\u53d1\u9001\u7684HTML\u6587\u4ef6\u540e&#xff0c;\u5c31\u4f1a\u628aHTML\u6587\u4ef6\u7684\u5185\u5bb9\u89e3\u6790\u6210\u6211\u4eec\u770b\u5230\u7684\u597d\u770b\u7684\u7f51\u9875\u3002<\/p>\n<h4>HTTP \u72b6\u6001\u7801<\/h4>\n<p>HTTP\u72b6\u6001\u7801\u662f\u670d\u52a1\u5668\u5bf9\u5ba2\u6237\u7aef\u8bf7\u6c42\u7684\u5904\u7406\u7ed3\u679c\u7684\u6807\u8bc6&#xff0c;\u5206\u4e3a5\u7c7b&#xff1a;<\/p>\n<p>1xx (\u4fe1\u606f\u6027\u72b6\u6001\u7801)<\/p>\n<ul>\n<li>100 Continue: \u7ee7\u7eed\u53d1\u9001\u8bf7\u6c42<\/li>\n<li>101 Switching Protocols: \u5207\u6362\u534f\u8bae<\/li>\n<\/ul>\n<p>2xx (\u6210\u529f\u72b6\u6001\u7801)<\/p>\n<ul>\n<li>200 OK: \u8bf7\u6c42\u6210\u529f<\/li>\n<li>201 Created: \u521b\u5efa\u6210\u529f<\/li>\n<li>204 No Content: \u6210\u529f\u4f46\u65e0\u8fd4\u56de\u5185\u5bb9<\/li>\n<li>206 Partial Content: \u90e8\u5206\u5185\u5bb9\u8bf7\u6c42\u6210\u529f<\/li>\n<\/ul>\n<p>3xx (\u91cd\u5b9a\u5411\u72b6\u6001\u7801)<\/p>\n<ul>\n<li>301 Moved Permanently: \u6c38\u4e45\u91cd\u5b9a\u5411<\/li>\n<li>302 Found: \u4e34\u65f6\u91cd\u5b9a\u5411<\/li>\n<li>304 Not Modified: \u8d44\u6e90\u672a\u4fee\u6539<\/li>\n<li>307 Temporary Redirect: \u4e34\u65f6\u91cd\u5b9a\u5411<\/li>\n<\/ul>\n<p>4xx (\u5ba2\u6237\u7aef\u9519\u8bef)<\/p>\n<ul>\n<li>400 Bad Request: \u8bf7\u6c42\u8bed\u6cd5\u9519\u8bef<\/li>\n<li>401 Unauthorized: \u672a\u6388\u6743<\/li>\n<li>403 Forbidden: \u7981\u6b62\u8bbf\u95ee<\/li>\n<li>404 Not Found: \u8d44\u6e90\u4e0d\u5b58\u5728<\/li>\n<li>405 Method Not Allowed: \u65b9\u6cd5\u4e0d\u5141\u8bb8<\/li>\n<li>429 Too Many Requests: \u8bf7\u6c42\u8fc7\u591a<\/li>\n<\/ul>\n<p>5xx (\u670d\u52a1\u5668\u9519\u8bef)<\/p>\n<ul>\n<li>500 Internal Server Error: \u670d\u52a1\u5668\u5185\u90e8\u9519\u8bef<\/li>\n<li>502 Bad Gateway: \u7f51\u5173\u9519\u8bef<\/li>\n<li>503 Service Unavailable: \u670d\u52a1\u4e0d\u53ef\u7528<\/li>\n<li>504 Gateway Timeout: \u7f51\u5173\u8d85\u65f6<\/li>\n<\/ul>\n<p>\u672c\u8282\u6559\u7a0b\u4e2d\u7684CONTENT\u7684\u5f00\u5934<\/p>\n<p>b&#034;\u201c\u201d HTTP\/1.0 200 OK\\\\r\\\\n Content-Type: text\/html; charset&#061;utf-8\\\\r\\\\n \\\\r\\\\n\\\\<\/p>\n<p>\u8fd9\u4e00\u6bb5\u5c31\u662fHTTP\u54cd\u5e94\u62a5\u6587\u7684\u5934\u90e8&#xff0c;\u91cc\u9762\u7684200\u5c31\u4ee3\u8868\u7740\u3010200 OK: \u8bf7\u6c42\u6210\u529f\u3011<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb710\u6b21\uff0c\u70b9\u8d5e11\u6b21\uff0c\u6536\u85cf11\u6b21\u3002\u4f7f\u7528K230\u4f5c\u4e3aHTTP\u670d\u52a1\u5668\u4f7f\u7528<\/p>\n","protected":false},"author":2,"featured_media":43395,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[151,810,4022,43],"topic":[],"class_list":["post-43397","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-http","tag-iphone","tag-k230","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>K230 \u8fd0\u884c HTTP \u670d\u52a1\u5668 httpserver - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/43397.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"K230 \u8fd0\u884c HTTP \u670d\u52a1\u5668 httpserver - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb710\u6b21\uff0c\u70b9\u8d5e11\u6b21\uff0c\u6536\u85cf11\u6b21\u3002\u4f7f\u7528K230\u4f5c\u4e3aHTTP\u670d\u52a1\u5668\u4f7f\u7528\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/43397.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-12T05:55:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250612055553-684a6be9e36c7.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/43397.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/43397.html\",\"name\":\"K230 \u8fd0\u884c HTTP \u670d\u52a1\u5668 httpserver - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-06-12T05:55:57+00:00\",\"dateModified\":\"2025-06-12T05:55:57+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/43397.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/43397.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/43397.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"K230 \u8fd0\u884c HTTP \u670d\u52a1\u5668 httpserver\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"K230 \u8fd0\u884c HTTP \u670d\u52a1\u5668 httpserver - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/43397.html","og_locale":"zh_CN","og_type":"article","og_title":"K230 \u8fd0\u884c HTTP \u670d\u52a1\u5668 httpserver - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb710\u6b21\uff0c\u70b9\u8d5e11\u6b21\uff0c\u6536\u85cf11\u6b21\u3002\u4f7f\u7528K230\u4f5c\u4e3aHTTP\u670d\u52a1\u5668\u4f7f\u7528","og_url":"https:\/\/www.wsisp.com\/helps\/43397.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-06-12T05:55:57+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250612055553-684a6be9e36c7.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/43397.html","url":"https:\/\/www.wsisp.com\/helps\/43397.html","name":"K230 \u8fd0\u884c HTTP \u670d\u52a1\u5668 httpserver - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-06-12T05:55:57+00:00","dateModified":"2025-06-12T05:55:57+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/43397.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/43397.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/43397.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"K230 \u8fd0\u884c HTTP \u670d\u52a1\u5668 httpserver"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/43397","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=43397"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/43397\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/43395"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=43397"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=43397"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=43397"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=43397"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}