{"id":122713,"date":"2026-11-05T13:57:54","date_gmt":"2026-11-05T05:57:54","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/122713.html"},"modified":"2026-11-05T13:57:54","modified_gmt":"2026-11-05T05:57:54","slug":"%e4%bb%8e%e9%9b%b6%e5%85%a5%e9%97%a8%e8%ae%a1%e7%ae%97%e6%9c%ba%e7%bd%91%e7%bb%9c%e7%b3%bb%e5%88%97%ef%bc%88%e4%b9%9d%ef%bc%89%ef%bc%9ahttp%e5%8d%8f%e8%ae%ae%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/122713.html","title":{"rendered":"\u4ece\u96f6\u5165\u95e8\u8ba1\u7b97\u673a\u7f51\u7edc\u7cfb\u5217\uff08\u4e5d\uff09\uff1aHTTP\u534f\u8bae\u8be6\u89e3\u2014\u2014\u4eceURL\u89e3\u6790\u5230\u8bf7\u6c42\u54cd\u5e94\u4e0e\u670d\u52a1\u5668\u5b9e\u6218"},"content":{"rendered":"<p>\u7b2c\u4e03\u671f\u6211\u4eec\u804a\u4e86\u600e\u4e48\u81ea\u5b9a\u4e49\u4e00\u4e2a\u5e94\u7528\u5c42\u534f\u8bae\u3002\u867d\u7136\u5634\u4e0a\u8bf4\u201c\u534f\u8bae\u662f\u7a0b\u5e8f\u5458\u81ea\u5df1\u5b9a\u7684\u201d&#xff0c;\u4f46\u73b0\u5b9e\u91cc&#xff0c;\u65e9\u6709\u4e00\u6279\u5927\u4f6c\u628a\u597d\u7528\u7684\u5e94\u7528\u5c42\u534f\u8bae\u5b9a\u4e49\u597d\u4e86&#xff0c;\u6446\u5728\u90a3\u513f\u4f9b\u6211\u4eec\u76f4\u63a5\u53c2\u8003\u3001\u76f4\u63a5\u4f7f\u7528\u3002HTTP&#xff08;\u8d85\u6587\u672c\u4f20\u8f93\u534f\u8bae&#xff09;&#xff0c;\u5c31\u662f\u5176\u4e2d\u6700\u7ecf\u5178\u7684\u4e00\u4e2a\u3002<\/p>\n<p>\u4ece\u672c\u6587\u5f00\u59cb&#xff0c;\u8fde\u7eed\u591a\u7bc7\u5185\u5bb9&#xff0c;\u6211\u4eec\u5c31\u628aHTTP\u534f\u8bae\u63b0\u5f00\u63c9\u788e&#xff0c;\u597d\u597d\u8bb2\u4e00\u8bb2\u3002<\/p>\n<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"%E4%B8%80%E3%80%81%E4%BB%80%E4%B9%88%E6%98%AF%20HTTP%20%E5%8D%8F%E8%AE%AE%EF%BC%9F-toc\" style=\"margin-left:80px\">\u4e00\u3001\u521d\u8bc6HTTP&#xff1a;\u7406\u89e3Web\u901a\u4fe1\u7684\u57fa\u672c\u534f\u8bae<\/p>\n<p id=\"%E4%BA%8C%E3%80%81%E4%BB%8E%E5%88%86%E6%9E%90%20URL%EF%BC%88%E7%BD%91%E5%9D%80%EF%BC%89%E5%88%9D%E6%AD%A5%E7%9C%8B%20HTTP%20%E5%8D%8F%E8%AE%AE-toc\" style=\"margin-left:80px\">\u4e8c\u3001\u4eceURL\u5165\u624b&#xff1a;\u7406\u89e3HTTP\u5982\u4f55\u5b9a\u4f4d\u7f51\u7edc\u8d44\u6e90<\/p>\n<p id=\"2.1%20%E5%8D%8F%E8%AE%AE-toc\" style=\"margin-left:120px\">2.1 URL\u4e2d\u7684\u534f\u8bae&#xff1a;HTTP\u4e0eHTTPS<\/p>\n<p id=\"2.2%20%E5%9F%9F%E5%90%8D-toc\" style=\"margin-left:120px\">2.2 \u57df\u540d&#xff1a;\u5982\u4f55\u627e\u5230\u76ee\u6807\u670d\u52a1\u5668<\/p>\n<p id=\"2.3%20%E8%B5%84%E6%BA%90%E8%AE%BF%E9%97%AE%E8%B7%AF%E5%BE%84-toc\" style=\"margin-left:120px\">2.3 \u8d44\u6e90\u8bbf\u95ee\u8def\u5f84&#xff1a;\u670d\u52a1\u5668\u4e0a\u7684\u5185\u5bb9\u5982\u4f55\u5b9a\u4f4d<\/p>\n<p id=\"2.3.1%20%E5%9C%A8%E7%BD%91%E7%BB%9C%E4%B8%AD%EF%BC%8C%E5%A6%82%E4%BD%95%E5%AE%9A%E4%B9%89%E2%80%9C%E8%B5%84%E6%BA%90%E2%80%9D-toc\" style=\"margin-left:160px\">2.3.1 \u4ec0\u4e48\u662f\u7f51\u7edc\u8d44\u6e90<\/p>\n<p id=\"2.3.2%20%E7%BD%91%E7%BB%9C%E8%B5%84%E6%BA%90%E5%AD%98%E6%94%BE%E7%9A%84%E8%B7%AF%E5%BE%84-toc\" style=\"margin-left:160px\">2.3.2 URL\u4e2d\u7684\u8def\u5f84&#xff1a;\u5982\u4f55\u8868\u793a\u8d44\u6e90\u7684\u4f4d\u7f6e<\/p>\n<p id=\"2.4%20%E6%88%91%E4%BB%AC%E5%A6%82%E4%BD%95%E8%AE%BF%E9%97%AE%E8%B5%84%E6%BA%90-toc\" style=\"margin-left:120px\">2.4 \u4ece\u8f93\u5165\u7f51\u5740\u5230\u8bbf\u95ee\u8d44\u6e90&#xff1a;\u57fa\u672c\u901a\u4fe1\u6d41\u7a0b<\/p>\n<p id=\"2.5%20%E6%80%BB%E7%BB%93-toc\" style=\"margin-left:120px\">2.5 \u5c0f\u7ed3<\/p>\n<p id=\"%E4%B8%89%E3%80%81HTTP%20%E8%AF%B7%E6%B1%82%E4%B8%8E%E5%93%8D%E5%BA%94%E6%A0%BC%E5%BC%8F-toc\" style=\"margin-left:80px\">\u4e09\u3001HTTP\u8bf7\u6c42\u4e0e\u54cd\u5e94&#xff1a;\u6df1\u5165\u7406\u89e3\u62a5\u6587\u683c\u5f0f<\/p>\n<p id=\"3.1%20HTTP%20%E8%AF%B7%E6%B1%82%E7%9A%84%E6%A0%BC%E5%BC%8F-toc\" style=\"margin-left:120px\">3.1 HTTP\u8bf7\u6c42\u62a5\u6587\u8be6\u89e3&#xff1a;\u5ba2\u6237\u7aef\u5982\u4f55\u53d1\u9001\u8bf7\u6c42<\/p>\n<p id=\"3.1.1%20%E8%AF%B7%E6%B1%82%E6%A0%BC%E5%BC%8F%E9%87%8C%E9%83%BD%E6%9C%89%E4%BB%80%E4%B9%88-toc\" style=\"margin-left:160px\">3.1.1 \u8bf7\u6c42\u62a5\u6587\u7684\u57fa\u672c\u7ed3\u6784&#xff1a;\u8bf7\u6c42\u884c\u3001\u8bf7\u6c42\u5934\u4e0e\u6d88\u606f\u4f53<\/p>\n<p id=\"3.1.2%20%E8%AF%B7%E6%B1%82%E6%A0%BC%E5%BC%8F%E7%9A%84%E7%BB%86%E8%8A%82-toc\" style=\"margin-left:160px\">3.1.2 \u6df1\u5165\u7406\u89e3HTTP\u8bf7\u6c42\u62a5\u6587\u7684\u7ec4\u7ec7\u65b9\u5f0f<\/p>\n<p id=\"3.1.2.1%20HTTP%20%E5%8D%8F%E8%AE%AE%E6%80%8E%E4%B9%88%E6%8A%8A%E6%8A%A5%E5%A4%B4%E5%92%8C%E6%9C%89%E6%95%88%E8%BD%BD%E8%8D%B7%E5%88%86%E5%BC%80%EF%BC%9F-toc\" style=\"margin-left:200px\">3.1.2.1 HTTP\u5982\u4f55\u533a\u5206\u62a5\u5934\u4e0e\u6d88\u606f\u4f53<\/p>\n<p id=\"3.1.2.2%20HTTP%20%E5%8D%8F%E8%AE%AE%E6%80%8E%E4%B9%88%E5%81%9A%E5%BA%8F%E5%88%97%E5%8C%96%E5%92%8C%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%EF%BC%9F-toc\" style=\"margin-left:200px\">3.1.2.2 HTTP\u62a5\u6587\u5982\u4f55\u7ec4\u88c5\u4e0e\u89e3\u6790&#xff1a;\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316<\/p>\n<p id=\"3.2%20HTTP%20%E5%93%8D%E5%BA%94%E7%9A%84%E6%A0%BC%E5%BC%8F-toc\" style=\"margin-left:120px\">3.2 HTTP\u54cd\u5e94\u62a5\u6587\u8be6\u89e3&#xff1a;\u670d\u52a1\u5668\u5982\u4f55\u8fd4\u56de\u7ed3\u679c<\/p>\n<p id=\"3.2.1%20%E5%93%8D%E5%BA%94%E6%A0%BC%E5%BC%8F%E9%87%8C%E9%83%BD%E6%9C%89%E4%BB%80%E4%B9%88-toc\" style=\"margin-left:160px\">3.2.1 \u54cd\u5e94\u62a5\u6587\u7684\u57fa\u672c\u7ed3\u6784&#xff1a;\u72b6\u6001\u884c\u3001\u54cd\u5e94\u5934\u4e0e\u6d88\u606f\u4f53<\/p>\n<p id=\"%E5%9B%9B%E3%80%81%E8%AE%BE%E8%AE%A1%E4%B8%80%E4%B8%AA%E7%AE%80%E5%8D%95%E7%9A%84%20HTTP%20%E6%9C%8D%E5%8A%A1%E5%99%A8%E2%80%94%E2%80%94%E5%8F%82%E8%80%83%E6%BA%90%E7%A0%81-toc\" style=\"margin-left:80px\">\u56db\u3001HTTP\u670d\u52a1\u5668\u5b9e\u6218&#xff1a;\u4ece\u534f\u8bae\u89e3\u6790\u5230\u7f51\u9875\u8bbf\u95ee<\/p>\n<p id=\"4.1%20Common.hpp%EF%BC%88%E9%94%99%E8%AF%AF%E7%A0%81%E4%B8%8E%E5%85%AC%E5%85%B1%E5%AE%9A%E4%B9%89%EF%BC%89-toc\" style=\"margin-left:120px\">4.1 Common.hpp&#xff08;\u9519\u8bef\u7801\u4e0e\u516c\u5171\u5b9a\u4e49&#xff09;<\/p>\n<p id=\"4.2%20Log.hpp%EF%BC%88%E6%97%A5%E5%BF%97%EF%BC%89-toc\" style=\"margin-left:120px\">4.2 Log.hpp&#xff08;\u65e5\u5fd7&#xff09;<\/p>\n<p id=\"4.3%20InetAddr.hpp%EF%BC%88IP%20%E5%9C%B0%E5%9D%80%E5%B0%81%E8%A3%85%EF%BC%89-toc\" style=\"margin-left:120px\">4.3 InetAddr.hpp&#xff08;IP \u5730\u5740\u5c01\u88c5&#xff09;<\/p>\n<p id=\"4.4%20Socket.hpp%EF%BC%88Socket%20%E5%B0%81%E8%A3%85%EF%BC%89-toc\" style=\"margin-left:120px\">4.4 Socket.hpp&#xff08;Socket \u5c01\u88c5&#xff09;<\/p>\n<p id=\"4.5%20HttpProtocol.hpp%EF%BC%88HTTP%20%E8%AF%B7%E6%B1%82%E8%A7%A3%E6%9E%90%E4%B8%8E%E5%93%8D%E5%BA%94%E6%9E%84%E5%BB%BA%EF%BC%89-toc\" style=\"margin-left:120px\">4.5 HttpProtocol.hpp&#xff08;HTTP \u8bf7\u6c42\u89e3\u6790\u4e0e\u54cd\u5e94\u6784\u5efa&#xff09;<\/p>\n<p id=\"4.6%20HttpServer.hpp%EF%BC%88HTTP%20%E6%9C%8D%E5%8A%A1%E5%99%A8%EF%BC%89-toc\" style=\"margin-left:120px\">4.6 HttpServer.hpp&#xff08;HTTP \u670d\u52a1\u5668&#xff09;<\/p>\n<p id=\"4.7%20HttpServer.cc%EF%BC%88%E4%B8%BB%E7%A8%8B%E5%BA%8F%EF%BC%89-toc\" style=\"margin-left:120px\">4.7 HttpServer.cc&#xff08;\u4e3b\u7a0b\u5e8f&#xff09;<\/p>\n<p id=\"4.8%20Makefile-toc\" style=\"margin-left:120px\">4.8 Makefile<\/p>\n<p id=\"4.9%20%E5%87%86%E5%A4%87%E4%B8%80%E4%B8%AA%E6%B5%8B%E8%AF%95%E9%A1%B5%E9%9D%A2-toc\" style=\"margin-left:120px\">4.9 \u51c6\u5907\u4e00\u4e2a\u6d4b\u8bd5\u9875\u9762<\/p>\n<p id=\"4.10%20%E8%BF%90%E8%A1%8C%E4%B8%8E%E9%AA%8C%E8%AF%81-toc\" style=\"margin-left:120px\">4.10 \u8fd0\u884c\u4e0e\u9a8c\u8bc1<\/p>\n<hr id=\"hr-toc\" \/>\n<h4 id=\"%E4%B8%80%E3%80%81%E4%BB%80%E4%B9%88%E6%98%AF%20HTTP%20%E5%8D%8F%E8%AE%AE%EF%BC%9F\" style=\"background-color:transparent\">\u4e00\u3001\u521d\u8bc6HTTP&#xff1a;\u7406\u89e3Web\u901a\u4fe1\u7684\u57fa\u672c\u534f\u8bae<\/h4>\n<p>\u5148\u7ed9\u4e00\u4e2a\u8bfe\u672c\u4e0a\u7684\u5b9a\u4e49&#xff1a;\u5728\u4e92\u8054\u7f51\u4e16\u754c\u91cc&#xff0c;HTTP&#xff08;HyperText Transfer Protocol&#xff0c;\u8d85\u6587\u672c\u4f20\u8f93\u534f\u8bae&#xff09;\u662f\u4e00\u4e2a\u81f3\u5173\u91cd\u8981\u7684\u534f\u8bae\u3002\u5b83\u89c4\u5b9a\u5ba2\u6237\u7aef&#xff08;\u6bd4\u5982\u6d4f\u89c8\u5668&#xff09;\u548c\u670d\u52a1\u5668\u4e4b\u95f4\u5982\u4f55\u901a\u4fe1&#xff0c;\u7528\u6765\u4ea4\u6362\u6216\u4f20\u8f93\u8d85\u6587\u672c&#xff0c;\u6bd4\u5982HTML\u6587\u6863\u3002<\/p>\n<p>HTTP\u662f\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u5668\u901a\u4fe1\u7684\u57fa\u7840\u3002\u5ba2\u6237\u7aef\u901a\u8fc7HTTP\u5411\u670d\u52a1\u5668\u53d1\u9001\u8bf7\u6c42&#xff0c;\u670d\u52a1\u5668\u6536\u5230\u8bf7\u6c42\u540e\u8fdb\u884c\u5904\u7406&#xff0c;\u518d\u8fd4\u56de\u54cd\u5e94\u3002HTTP\u662f\u4e00\u4e2a\u65e0\u8fde\u63a5\u3001\u65e0\u72b6\u6001\u7684\u534f\u8bae&#xff1a;\u6bcf\u6b21\u8bf7\u6c42\u90fd\u50cf\u4e00\u6b21\u72ec\u7acb\u7684\u5bf9\u8bdd&#xff0c;\u9700\u8981\u91cd\u65b0\u5efa\u7acb\u8fde\u63a5&#xff0c;\u670d\u52a1\u5668\u4e5f\u4e0d\u4f1a\u4fdd\u5b58\u5ba2\u6237\u7aef\u7684\u72b6\u6001\u4fe1\u606f\u3002<\/p>\n<h4 id=\"%E4%BA%8C%E3%80%81%E4%BB%8E%E5%88%86%E6%9E%90%20URL%EF%BC%88%E7%BD%91%E5%9D%80%EF%BC%89%E5%88%9D%E6%AD%A5%E7%9C%8B%20HTTP%20%E5%8D%8F%E8%AE%AE\" style=\"background-color:transparent\">\u4e8c\u3001\u4eceURL\u5165\u624b&#xff1a;\u7406\u89e3HTTP\u5982\u4f55\u5b9a\u4f4d\u7f51\u7edc\u8d44\u6e90<\/h4>\n<h5 id=\"2.1%20%E5%8D%8F%E8%AE%AE\">2.1 URL\u4e2d\u7684\u534f\u8bae&#xff1a;HTTP\u4e0eHTTPS<\/h5>\n<p>\u7f51\u5740\u5f00\u5934\u8fd9\u4e2ahttps&#xff0c;\u6216\u8005http&#xff0c;\u8868\u793a\u7684\u662f\u83b7\u53d6\u8d44\u6e90\u65f6\u91c7\u7528\u7684\u534f\u8bae\u3002\u6210\u719f\u7684\u534f\u8bae&#xff0c;\u7aef\u53e3\u53f7\u5f80\u5f80\u662f\u56fa\u5b9a\u7684&#xff0c;https\u8d70443&#xff0c;http\u8d7080&#xff0c;ssh\u8d7022\u3002\u8fd9\u4e5f\u4ece\u4fa7\u9762\u5370\u8bc1\u4e86\u4e00\u4ef6\u4e8b&#xff1a;0~1023\u8fd9\u6bb5\u7aef\u53e3\u53f7&#xff0c;\u4e0d\u662f\u8c01\u60f3\u7528\u5c31\u80fd\u7528\u7684\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"63\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105055746-6aec1ada94fe1.png\" width=\"692\" \/><\/p>\n<h5 id=\"2.2%20%E5%9F%9F%E5%90%8D\">2.2 \u57df\u540d&#xff1a;\u5982\u4f55\u627e\u5230\u76ee\u6807\u670d\u52a1\u5668<\/h5>\n<p>\u4f60\u53ef\u4ee5\u7b80\u5355\u5730\u628a\u57df\u540d\u7406\u89e3\u6210IP\u5730\u5740\u7684\u201c\u95e8\u724c\u53f7\u201d\u3002\u57df\u540d\u6700\u7ec8\u8981\u89e3\u6790\u6210IP\u5730\u5740&#xff0c;\u8bbf\u95ee\u7684\u5176\u5b9e\u5c31\u662f\u8fd9\u5bb6\u516c\u53f8\u7684\u670d\u52a1\u5668\u3002\u90a3\u4e3a\u4ec0\u4e48\u4e0d\u76f4\u63a5\u7528IP&#xff1f;\u56e0\u4e3aIP\u5730\u5740\u6ca1\u6709\u8868\u610f\u6027&#xff0c;\u4e00\u4e32\u6570\u5b57\u6446\u5728\u90a3\u513f&#xff0c;\u8c01\u77e5\u9053\u5b83\u662f\u8c01\u5bb6\u7684\u670d\u52a1\u5668\u3002\u57df\u540d\u4e0d\u4e00\u6837&#xff0c;\u4e00\u770b\u540d\u5b57&#xff0c;\u5927\u6982\u5c31\u80fd\u731c\u5230\u8fd9\u662f\u5e72\u4ec0\u4e48\u7684\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"75\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105055746-6aec1adaa17c3.png\" width=\"720\" \/><\/p>\n<h5 id=\"2.3%20%E8%B5%84%E6%BA%90%E8%AE%BF%E9%97%AE%E8%B7%AF%E5%BE%84\">2.3 \u8d44\u6e90\u8bbf\u95ee\u8def\u5f84&#xff1a;\u670d\u52a1\u5668\u4e0a\u7684\u5185\u5bb9\u5982\u4f55\u5b9a\u4f4d<\/h5>\n<h6 id=\"2.3.1%20%E5%9C%A8%E7%BD%91%E7%BB%9C%E4%B8%AD%EF%BC%8C%E5%A6%82%E4%BD%95%E5%AE%9A%E4%B9%89%E2%80%9C%E8%B5%84%E6%BA%90%E2%80%9D\">2.3.1 \u4ec0\u4e48\u662f\u7f51\u7edc\u8d44\u6e90<\/h6>\n<p>\u5148\u6765\u60f3\u4e00\u4e2a\u95ee\u9898&#xff1a;\u8d44\u6e90&#xff0c;\u5230\u5e95\u662f\u4ec0\u4e48&#xff1f;<\/p>\n<p>\u4eba\u7684\u4e0a\u7f51\u884c\u4e3a&#xff0c;\u8bf4\u767d\u4e86\u5c31\u4e24\u79cd&#xff0c;\u4ece\u8fdc\u7aef\u62ff\u6570\u636e\u4e0b\u6765&#xff0c;\u628a\u672c\u5730\u6570\u636e\u4f20\u4e0a\u53bb\u3002 \u62ff\u7684\u3001\u4f20\u7684&#xff0c;\u53ef\u80fd\u662f\u77ed\u89c6\u9891\u3001\u7f51\u9875\u3001\u56fe\u7247\u3001\u97f3\u9891&#xff0c;\u4e5f\u53ef\u80fd\u662f\u4efb\u4f55\u4e00\u4e2a\u6587\u4ef6\u3002<\/p>\n<p>\u90a3\u95ee\u9898\u6765\u4e86&#xff1a;\u4f60\u6ca1\u83b7\u53d6\u5b83\u7684\u65f6\u5019&#xff0c;\u8fd9\u4e9b\u8d44\u6e90\u5728\u54ea\u513f&#xff1f;<\/p>\n<p>\u7b54\u6848&#xff1a;\u5728Linux\u670d\u52a1\u5668\u5185\u90e8\u3002<\/p>\n<p>\u4ee5\u4ec0\u4e48\u5f62\u5f0f\u5b58\u5728&#xff1f;\u4e00\u4e2a\u6587\u4ef6&#xff0c;\u5c31\u662f\u4e00\u4efd\u201c\u8d44\u6e90\u201d\u3002 \u7f51\u9875\u662f\u6587\u4ef6&#xff0c;\u56fe\u7247\u662f\u6587\u4ef6&#xff0c;\u89c6\u9891\u4e5f\u662f\u6587\u4ef6\u3002\u7f51\u7edc\u90a3\u5934&#xff0c;\u670d\u52a1\u5668\u91cc\u8eba\u7740\u7684&#xff0c;\u5c31\u662f\u4e00\u4e2a\u4e00\u4e2a\u7684\u6587\u4ef6\u3002\u6240\u8c13\u7684\u201c\u8bbf\u95ee\u8d44\u6e90\u201d&#xff0c;\u8bf4\u5230\u5e95&#xff0c;\u5c31\u662f\u53bb\u670d\u52a1\u5668\u4e0a\u53d6\u67d0\u4e2a\u6587\u4ef6\u3002<\/p>\n<h6 id=\"2.3.2%20%E7%BD%91%E7%BB%9C%E8%B5%84%E6%BA%90%E5%AD%98%E6%94%BE%E7%9A%84%E8%B7%AF%E5%BE%84\">2.3.2 URL\u4e2d\u7684\u8def\u5f84&#xff1a;\u5982\u4f55\u8868\u793a\u8d44\u6e90\u7684\u4f4d\u7f6e<\/h6>\n<p>\u56de\u5230\u8fd9\u91cc&#xff0c;\/2201_76111162?type&#061;lately\u5c31\u53ef\u4ee5\u7406\u89e3\u4e3a\u4e00\u4efd\u8d44\u6e90\u5b58\u653e\u7684\u8def\u5f84\u3002<\/p>\n<p>\u6700\u524d\u9762\u90a3\u4e2a\/&#xff0c;\u4ee3\u8868\u7684\u662fWeb\u6839\u76ee\u5f55\u3002\u6ce8\u610f&#xff0c;Web\u6839\u76ee\u5f55\u4e0d\u662fLinux\u7684\u6839\u76ee\u5f55&#xff0c;\u8fd9\u91cc\u5148\u57cb\u4e2a\u4f0f\u7b14&#xff0c;\u540e\u9762\u518d\u5c55\u5f00\u3002<\/p>\n<p>\u4e2d\u95f4\u90a3\u4e9b\/&#xff0c;\u5c31\u662fLinux\u7684\u8def\u5f84\u5206\u9694\u7b26\u3002\u987a\u7740\u8fd9\u6761\u8def\u5f84\u627e\u4e0b\u53bb&#xff0c;\u8d44\u6e90\u5c31\u662f\u670d\u52a1\u5668\u4e0b\u5bf9\u5e94\u7684\u90a3\u4e2a\u6587\u4ef6\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"56\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105055746-6aec1adaabf58.png\" width=\"723\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"46\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105055746-6aec1adab6126.png\" width=\"747\" \/><\/p>\n<h5 id=\"2.4%20%E6%88%91%E4%BB%AC%E5%A6%82%E4%BD%95%E8%AE%BF%E9%97%AE%E8%B5%84%E6%BA%90\">2.4 \u4ece\u8f93\u5165\u7f51\u5740\u5230\u8bbf\u95ee\u8d44\u6e90&#xff1a;\u57fa\u672c\u901a\u4fe1\u6d41\u7a0b<\/h5>\n<p>\u9996\u5148&#xff0c;\u8fd0\u8425\u5546\u548c\u5404\u7ea7DNS\u4f53\u7cfb\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u57df\u540d\u89e3\u6790\u670d\u52a1\u3002\u6211\u4eec\u5728\u6d4f\u89c8\u5668\u91cc\u8f93\u5165URL&#xff0c;\u6d4f\u89c8\u5668\u4f1a\u5148\u53bb\u95ee\u57df\u540d\u670d\u52a1\u5668&#xff1a;\u8fd9\u4e2a\u57df\u540d\u5bf9\u5e94\u54ea\u4e2aIP&#xff1f;\u57df\u540d\u670d\u52a1\u5668\u7ffb\u51fa\u4e00\u672c\u5e9e\u5927\u7684\u201c\u7535\u8bdd\u7c3f\u201d&#xff0c;DNS\u8bb0\u5f55\u8868&#xff0c;\u5728\u91cc\u9762\u68c0\u7d22&#xff0c;\u628a\u57df\u540d\u7cbe\u51c6\u7ffb\u8bd1\u6210\u5bf9\u5e94\u7684IP\u5730\u5740\u3002<\/p>\n<p>\u62ff\u5230IP\u4e4b\u540e&#xff0c;\u6d4f\u89c8\u5668\u518d\u7ed3\u5408\u7aef\u53e3\u53f7&#xff08;\u5177\u4f53\u7528\u54ea\u4e2a\u7aef\u53e3&#xff0c;\u53d6\u51b3\u4e8e\u4f60\u91c7\u7528\u7684\u662fHTTP\u8fd8\u662fHTTPS&#xff09;&#xff0c;\u5c31\u80fd\u8bbf\u95ee\u5bf9\u5e94\u7684\u670d\u52a1\u5668&#xff0c;\u5e76\u987a\u7740\u57df\u540d\u540e\u9762\u7684\u8d44\u6e90\u8bbf\u95ee\u8def\u5f84&#xff0c;\u53d6\u56de\u60f3\u8981\u7684\u90a3\u4efd\u8d44\u6e90\u3002<\/p>\n<p>\u53bbping\u4e00\u4e0b\u767e\u5ea6\u7684\u7f51\u5740&#xff0c;\u80fd\u770b\u5230\u7c7b\u4f3c\u8fd9\u6837\u7684\u8f93\u51fa&#xff1a;<\/p>\n<p>\u6b63\u5728 Ping www.a.shifen.com [2409:8c54:870:187:0:ff:b0d9:bb1c] \u5177\u6709 32 \u5b57\u8282\u7684\u6570\u636e:<br \/>\n\u6765\u81ea 2409:8c54:870:187:0:ff:b0d9:bb1c \u7684\u56de\u590d: \u65f6\u95f4&#061;551ms<br \/>\n\u6765\u81ea 2409:8c54:870:187:0:ff:b0d9:bb1c \u7684\u56de\u590d: \u65f6\u95f4&#061;529ms<br \/>\n\u6765\u81ea 2409:8c54:870:187:0:ff:b0d9:bb1c \u7684\u56de\u590d: \u65f6\u95f4&#061;352ms<br \/>\n\u6765\u81ea 2409:8c54:870:187:0:ff:b0d9:bb1c \u7684\u56de\u590d: \u65f6\u95f4&#061;597ms <\/p>\n<p>\u65b9\u62ec\u53f7\u91cc\u90a3\u4e322409:8c54:870:187:0:ff:b0d9:bb1c&#xff0c;\u5c31\u662fIP\u5730\u5740\u3002\u6709\u4e86IP\u5730\u5740&#xff0c;\u518d\u52a0\u4e0a\u7aef\u53e3\u53f7&#xff0c;\u5c31\u80fd\u5b9a\u4f4d\u5230\u76ee\u6807\u670d\u52a1\u5668\u3002\u800c\u6211\u4eec\u5e73\u65f6\u5728\u6d4f\u89c8\u5668\u91cc\u8f93\u5165\u7684&#xff0c;\u662f\u201c\u534f\u8bae &#043; \u57df\u540d\u201d&#xff0c;DNS\u8d1f\u8d23\u628a\u57df\u540d\u7ffb\u8bd1\u6210IP&#xff0c;\u5269\u4e0b\u7684\u8def&#xff0c;\u6d4f\u89c8\u5668\u81ea\u5df1\u4f1a\u8d70\u3002<\/p>\n<p>Tips&#xff1a;\u4e3a\u4ec0\u4e48\u8fd9\u4e2aIP\u5730\u5740\u770b\u8d77\u6765\u8fd9\u4e48\u5947\u602a&#xff1f;<\/p>\n<p>\u56e0\u4e3a\u5b83\u662fIPv6\u5730\u5740\u3002\u6211\u4eec\u5e73\u5e38\u770b\u5230\u7684&#xff0c;\u5927\u591a\u662fIPv4\u3002<\/p>\n<p>PS C:\\\\Windows\\\\System32\\\\WindowsPowerShell\\\\v1.0&gt; ping www.baidu.com<\/p>\n<p>\u6b63\u5728 Ping www.a.shifen.com [2409:8c54:870:187:0:ff:b0d9:bb1c] \u5177\u6709 32 \u5b57\u8282\u7684\u6570\u636e:<br \/>\n\u6765\u81ea 2409:8c54:870:187:0:ff:b0d9:bb1c \u7684\u56de\u590d: \u65f6\u95f4&#061;551ms<br \/>\n\u6765\u81ea 2409:8c54:870:187:0:ff:b0d9:bb1c \u7684\u56de\u590d: \u65f6\u95f4&#061;529ms<br \/>\n\u6765\u81ea 2409:8c54:870:187:0:ff:b0d9:bb1c \u7684\u56de\u590d: \u65f6\u95f4&#061;352ms<br \/>\n\u6765\u81ea 2409:8c54:870:187:0:ff:b0d9:bb1c \u7684\u56de\u590d: \u65f6\u95f4&#061;597ms<\/p>\n<p>2409:8c54:870:187:0:ff:b0d9:bb1c \u7684 Ping \u7edf\u8ba1\u4fe1\u606f:<br \/>\n    \u6570\u636e\u5305: \u5df2\u53d1\u9001 &#061; 4&#xff0c;\u5df2\u63a5\u6536 &#061; 4&#xff0c;\u4e22\u5931 &#061; 0 (0% \u4e22\u5931)&#xff0c;<br \/>\n\u5f80\u8fd4\u884c\u7a0b\u7684\u4f30\u8ba1\u65f6\u95f4(\u4ee5\u6beb\u79d2\u4e3a\u5355\u4f4d):<br \/>\n    \u6700\u77ed &#061; 352ms&#xff0c;\u6700\u957f &#061; 597ms&#xff0c;\u5e73\u5747 &#061; 507ms<br \/>\nPS C:\\\\Windows\\\\System32\\\\WindowsPowerShell\\\\v1.0&gt; <\/p>\n<p>\u5386\u53f2\u8865\u5145&#xff1a;\u56fe\u4e2d\u6846\u51fa\u6765\u7684\u4e24\u4e2a\u5b57\u6bb5&#xff0c;\u66fe\u7ecf\u5b58\u5728\u8fc7&#xff0c;\u5982\u4eca\u5df2\u7ecf\u88ab\u5e9f\u5f03\u4e86\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"440\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105055746-6aec1adabfc9e.png\" width=\"1410\" \/><\/p>\n<h5 id=\"2.5%20%E6%80%BB%E7%BB%93\">2.5 \u5c0f\u7ed3<\/h5>\n<p>\u7ad9\u5728HTTP\u7684\u89d2\u5ea6\u770b&#xff0c;\u201c\u8d44\u6e90\u201d\u672c\u8d28\u4e0a\u5c31\u662f\u5b58\u653e\u5728Linux\u670d\u52a1\u5668\u7279\u5b9a\u8def\u5f84\u4e0b\u7684\u4e00\u4e2a\u6587\u4ef6\u3002<\/p>\n<p>\u6211\u4eec\u5728URL\u91cc\u770b\u5230\u7684\u534f\u8bae\u4e0e\u7aef\u53e3\u53f7&#xff08;http\/https\u52a0\u7aef\u53e3&#xff09;\u3001\u57df\u540d&#xff08;\u6620\u5c04\u5230\u5177\u6709\u552f\u4e00\u6027\u7684IP\u5730\u5740&#xff09;&#xff0c;\u4ee5\u53ca\u8def\u5f84&#xff08;\u76ee\u6807\u673a\u5668\u4e0a\u67d0\u4e2a\u7279\u5b9a\u6587\u4ef6\u7684\u4f4d\u7f6e&#xff09;&#xff0c;\u8fd9\u4e09\u6837\u4e1c\u897f\u51d1\u5728\u4e00\u8d77&#xff0c;\u5c31\u6784\u6210\u4e86\u5168\u7f51\u552f\u4e00\u7684\u6587\u4ef6\u5b9a\u4f4d\u3002<\/p>\n<p>\u6240\u4ee5&#xff0c;\u8d85\u6587\u672c\u4f20\u8f93\u534f\u8bae\u7684\u672c\u8d28&#xff0c;\u5c31\u662f\u7528\u6765\u4f20\u6587\u4ef6\u7684\u3002\u800c\u5b83\u5e95\u5c42&#xff0c;\u4f9d\u7136\u662f\u57fa\u4e8eSocket\u5b9e\u73b0\u7684\u7f51\u7edc\u901a\u4fe1\u3002<\/p>\n<p>Tips&#xff1a;urlencode\u548curldecode&#xff08;\u8865\u5145\u5185\u5bb9&#xff09;<\/p>\n<p>\u6211\u4eec\u8bd5\u7740\u641c\u7d22\u4e00\u4e0b<span style=\"color:#fe2c24\">hello: \/\/&#064;world<\/span>\u3002<\/p>\n<p>\u53ef\u4ee5\u770b\u5230&#xff0c;\u641c\u7d22\u6846\u91cc\u8f93\u5165\u7684\u7279\u6b8a\u5b57\u7b26&#xff0c;\u5230\u4e86URL\u91cc\u5c31\u53d8\u6210\u4e86<span style=\"color:#fe2c24\">%20\u3001%3A\u3001%2F\u3001%40<\/span>\u8fd9\u6837\u4e00\u4e32\u4e1c\u897f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"114\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105055747-6aec1adb1f090.png\" width=\"800\" \/><\/p>\n<p>\u50cf :<span style=\"color:#fe2c24\">\u3001\/\u3001&#064;<\/span>\u4ee5\u53ca\u7a7a\u683c\u8fd9\u4e9b\u5b57\u7b26&#xff0c;\u5728URL\u91cc\u90fd\u6709\u7279\u6b8a\u7528\u9014\u6216\u5206\u9694\u542b\u4e49\u3002\u8981\u662f\u8ba9\u5b83\u4eec\u76f4\u63a5\u51fa\u73b0\u5728\u53c2\u6570\u91cc&#xff0c;\u5ba2\u6237\u7aef\u6216\u670d\u52a1\u5668\u89e3\u6790URL\u65f6\u5c31\u4f1a\u72af\u8ff7\u7cca&#xff0c;\u8f7b\u5219\u89e3\u6790\u51fa\u9519&#xff0c;\u91cd\u5219\u76f4\u63a5\u5931\u8d25\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"365\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105055747-6aec1adb2fc38.png\" width=\"1501\" \/><\/p>\n<p>\u4e3a\u4e86\u907f\u514d\u6b67\u4e49&#xff0c;\u5ba2\u6237\u7aef&#xff08;\u6bd4\u5982\u6d4f\u89c8\u5668&#xff09;\u5728\u5411\u670d\u52a1\u5668\u53d1\u8bf7\u6c42\u4e4b\u524d&#xff0c;\u4f1a\u81ea\u52a8\u628aURL\u91cc\u7684\u7279\u6b8a\u5b57\u7b26\u8f6c\u6210\u5341\u516d\u8fdb\u5236\u5f62\u5f0f\u3002\u8fd9\u4e2a\u8f6c\u7801\u8fc7\u7a0b&#xff0c;\u53eburlencode\u3002\u670d\u52a1\u5668\u6536\u5230\u8bf7\u6c42\u540e&#xff0c;\u518d\u628a\u5b83\u8fd8\u539f\u6210\u539f\u59cb\u5b57\u7b26&#xff0c;\u8fd9\u4e2a\u89e3\u7801\u8fc7\u7a0b&#xff0c;\u53eburldecode\u3002<\/p>\n<p>\u6d4f\u89c8\u5668\u8d1f\u8d23\u7f16\u7801&#xff0c;\u670d\u52a1\u5668\u8d1f\u8d23\u89e3\u7801&#xff0c;\u8fd9\u79cd\u914d\u5408\u6a21\u5f0f&#xff0c;\u6b63\u662f\u5178\u578b\u7684B\/S&#xff08;Browser\/Server&#xff09;\u67b6\u6784\u3002\u6211\u4eec\u4ee5\u524d\u5199\u7684&#xff0c;\u662fC\/S\u67b6\u6784\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"161\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105055747-6aec1adb5d9d9.png\" width=\"718\" \/><\/p>\n<p>\u8f6c\u4e49\u89c4\u5219&#xff1a;\u628a\u9700\u8981\u8f6c\u7801\u7684\u5b57\u7b26\u8f6c\u6210\u5341\u516d\u8fdb\u5236&#xff0c;\u4ece\u53f3\u5f80\u5de6\u53d64\u4f4d&#xff08;\u4e0d\u8db34\u4f4d\u76f4\u63a5\u5904\u7406&#xff09;&#xff0c;\u6bcf2\u4f4d\u7b97\u4e00\u7ec4&#xff0c;\u524d\u9762\u52a0\u4e0a%&#xff0c;\u7f16\u7801\u6210%XY\u7684\u683c\u5f0f\u3002<\/p>\n<h4 id=\"%E4%B8%89%E3%80%81HTTP%20%E8%AF%B7%E6%B1%82%E4%B8%8E%E5%93%8D%E5%BA%94%E6%A0%BC%E5%BC%8F\">\u4e09\u3001HTTP\u8bf7\u6c42\u4e0e\u54cd\u5e94&#xff1a;\u6df1\u5165\u7406\u89e3\u62a5\u6587\u683c\u5f0f<\/h4>\n<h5 id=\"3.1%20HTTP%20%E8%AF%B7%E6%B1%82%E7%9A%84%E6%A0%BC%E5%BC%8F\">3.1 HTTP\u8bf7\u6c42\u62a5\u6587\u8be6\u89e3&#xff1a;\u5ba2\u6237\u7aef\u5982\u4f55\u53d1\u9001\u8bf7\u6c42<\/h5>\n<h6 id=\"3.1.1%20%E8%AF%B7%E6%B1%82%E6%A0%BC%E5%BC%8F%E9%87%8C%E9%83%BD%E6%9C%89%E4%BB%80%E4%B9%88\" style=\"background-color:transparent\">3.1.1 \u8bf7\u6c42\u62a5\u6587\u7684\u57fa\u672c\u7ed3\u6784&#xff1a;\u8bf7\u6c42\u884c\u3001\u8bf7\u6c42\u5934\u4e0e\u6d88\u606f\u4f53<\/h6>\n<p>\u62ff\u5230\u4e00\u4e2aHTTP\u8bf7\u6c42\u62a5\u6587&#xff0c;\u6211\u4eec\u6765\u62c6\u5f00\u770b\u770b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"670\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105055747-6aec1adb7178e.png\" width=\"1289\" \/><\/p>\n<ul>\n<li>\n<p>\u9996\u884c&#xff1a;<span style=\"color:#fe2c24\">[\u65b9\u6cd5] &#043; [url] &#043; [\u7248\u672c]<\/span>\u3002\u4e09\u4e2a\u90e8\u5206&#xff0c;\u4e00\u53e5\u8bdd\u4ea4\u4ee3\u6e05\u695a\u201c\u7528\u4ec0\u4e48\u65b9\u5f0f\u3001\u8bbf\u95ee\u54ea\u4e2a\u8d44\u6e90\u3001\u7528\u7684\u54ea\u4e2a HTTP \u7248\u672c\u201d\u3002<\/p>\n<\/li>\n<li>\n<p>Header&#xff1a;\u8bf7\u6c42\u7684\u5404\u79cd\u5c5e\u6027&#xff0c;\u4e00\u5806\u5192\u53f7\u5206\u5272\u7684\u952e\u503c\u5bf9\u3002\u6bcf\u7ec4\u5c5e\u6027\u4e4b\u95f4\u7528<span style=\"color:#fe2c24\">\\\\r\\\\n<\/span>\u9694\u5f00&#xff1b;\u78b0\u5230\u4e00\u4e2a\u7a7a\u884c&#xff0c;Header\u90e8\u5206\u5c31\u5230\u6b64\u4e3a\u6b62\u3002<\/p>\n<\/li>\n<li>\n<p>Body&#xff1a;\u7a7a\u884c\u540e\u9762\u7684\u5185\u5bb9&#xff0c;\u5168\u5f52Body\u3002Body\u5141\u8bb8\u662f\u7a7a\u5b57\u7b26\u4e32\u3002\u5982\u679cBody\u5b58\u5728&#xff0c;Header\u91cc\u4f1a\u6709\u4e00\u4e2aContent-Length\u5c5e\u6027&#xff0c;\u4e13\u95e8\u6807\u660eBody\u6709\u591a\u957f&#xff08;\u8fd9\u4e2a\u540e\u9762\u7ec6\u8bb2&#xff09;\u3002<\/p>\n<\/li>\n<\/ul>\n<p>HTTP\u7684\u5e95\u5c42\u662fTCP&#xff0c;\u8fd9\u4e00\u70b9&#xff0c;\u7b49\u540e\u9762\u5199\u4ee3\u7801\u7684\u65f6\u5019&#xff0c;\u81ea\u7136\u5c31\u80fd\u4f53\u4f1a\u5230\u3002<\/p>\n<p>\u628a\u4e0a\u9762\u8fd9\u4e2a\u62a5\u6587\u62bd\u8c61\u4e00\u4e0b&#xff0c;\u5c31\u80fd\u5f97\u5230\u4e0b\u9762\u8fd9\u6837\u4e00\u4e2a\u7ed3\u6784\u56fe&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"900\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105055748-6aec1adc1f597.png\" width=\"1747\" \/><\/p>\n<h6 id=\"3.1.2%20%E8%AF%B7%E6%B1%82%E6%A0%BC%E5%BC%8F%E7%9A%84%E7%BB%86%E8%8A%82\" style=\"background-color:transparent\">3.1.2 \u6df1\u5165\u7406\u89e3HTTP\u8bf7\u6c42\u62a5\u6587\u7684\u7ec4\u7ec7\u65b9\u5f0f<\/h6>\n<p>\u6574\u4e2aHTTP\u8bf7\u6c42\u62a5\u6587&#xff0c;\u653e\u5728\u7f51\u7edc\u91cc\u4f20\u8f93\u7684\u65f6\u5019&#xff0c;\u672c\u8d28\u4e0a\u5c31\u662f\u4e00\u6bb5\u591a\u884c\u7684\u5b57\u7b26\u4e32\u3002\u6ca1\u4ec0\u4e48\u7384\u4e4e\u7684&#xff0c;\u5c31\u662f\u4e00\u4e32\u5b57\u7b26&#xff0c;\u6309\u89c4\u77e9\u6392\u597d\u961f\u800c\u5df2\u3002<\/p>\n<h6 id=\"3.1.2.1%20HTTP%20%E5%8D%8F%E8%AE%AE%E6%80%8E%E4%B9%88%E6%8A%8A%E6%8A%A5%E5%A4%B4%E5%92%8C%E6%9C%89%E6%95%88%E8%BD%BD%E8%8D%B7%E5%88%86%E5%BC%80%EF%BC%9F\">3.1.2.1 HTTP\u5982\u4f55\u533a\u5206\u62a5\u5934\u4e0e\u6d88\u606f\u4f53<\/h6>\n<p>\u9760\u4e00\u4e2a\u7a7a\u884c\u3002HTTP\u534f\u8bae\u62ff<span style=\"color:#fe2c24\">\\\\r\\\\n<\/span>\u5f53\u5206\u9694\u7b26&#xff0c;\u628a\u62a5\u5934\u548c\u6709\u6548\u8f7d\u8377\u4e00\u5200\u5207\u5f00\u3002\u89e3\u6790\u62a5\u6587\u7684\u65f6\u5019&#xff0c;\u7cfb\u7edf\u6309\u884c\u5f80\u4e0b\u8bfb&#xff0c;\u4e00\u65e6\u8bfb\u5230\u4e00\u884c\u5149\u79c3\u79c3\u7684\u3001\u53ea\u6709\u6362\u884c\u7b26\u7684\u7a7a\u884c&#xff0c;\u5c31\u77e5\u9053&#xff1a;\u62a5\u5934\u5230\u6b64\u4e3a\u6b62&#xff0c;\u518d\u5f80\u540e\u7684\u5185\u5bb9&#xff0c;\u5168\u662f\u6709\u6548\u8f7d\u8377&#xff08;Body&#xff09;\u3002<\/p>\n<p>\u5c31\u50cf\u4e00\u5c01\u4fe1&#xff0c;\u6b63\u6587\u5199\u5b8c\u4e86&#xff0c;\u843d\u6b3e\u548c\u4fe1\u5c01\u4fe1\u606f\u4e4b\u95f4\u7a7a\u4e00\u884c&#xff0c;\u8bfb\u4fe1\u7684\u4eba\u4e00\u770b\u7a7a\u884c&#xff0c;\u5c31\u660e\u767d\u201c\u524d\u9762\u662f\u4fe1\u7684\u5185\u5bb9&#xff0c;\u540e\u9762\u662f\u5bc4\u4ef6\u4fe1\u606f\u201d\u3002HTTP\u7528\u7684\u662f\u540c\u4e00\u4e2a\u601d\u8def&#xff0c;\u4e00\u4e2a\u7a7a\u884c&#xff0c;\u5e72\u51c0\u5229\u843d\u3002<\/p>\n<h6 id=\"3.1.2.2%20HTTP%20%E5%8D%8F%E8%AE%AE%E6%80%8E%E4%B9%88%E5%81%9A%E5%BA%8F%E5%88%97%E5%8C%96%E5%92%8C%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%EF%BC%9F\">3.1.2.2 HTTP\u62a5\u6587\u5982\u4f55\u7ec4\u88c5\u4e0e\u89e3\u6790&#xff1a;\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316<\/h6>\n<p>\u975e\u5e38\u76f4\u63a5&#xff0c;\u751a\u81f3\u53ef\u4ee5\u8bf4\u6734\u7d20\u3002<\/p>\n<p>\u5b83\u4e0d\u4f9d\u8d56\u4efb\u4f55\u590d\u6742\u7684\u7b2c\u4e09\u65b9\u5e93&#xff0c;\u5c31\u662f\u62ff\u7279\u6b8a\u5b57\u7b26\u5f53\u523b\u5200&#xff0c;\u5bf9\u5b57\u7b26\u4e32\u505a\u62fc\u63a5\u548c\u5207\u5272\u3002\u53d1\u9001\u7aef&#xff0c;\u628a\u5185\u5b58\u91cc\u7684\u7ed3\u6784\u5316\u8bf7\u6c42\u6570\u636e&#xff0c;\u6309\u89c4\u8303\u4e00\u6bb5\u4e00\u6bb5\u62fc\u6210\u5b57\u7b26\u4e32&#xff0c;\u8fd9\u5c31\u662f\u5e8f\u5217\u5316\u3002<span style=\"background-color:#ffd900\">\u63a5\u6536\u7aef&#xff0c;\u518d\u5bf9\u7740\u8fd9\u4e9b\u7279\u6b8a\u5b57\u7b26&#xff0c;\u628a\u5b57\u7b26\u4e32\u91cd\u65b0\u62c6\u5f00\u3001\u63d0\u53d6&#xff0c;\u8fd8\u539f\u6210\u7ed3\u6784\u5316\u5bf9\u8c61&#xff0c;\u8fd9\u5c31\u662f\u53cd\u5e8f\u5217\u5316<\/span>\u3002<\/p>\n<p>\u6ca1\u6709Protobuf\u90a3\u5957\u4e8c\u8fdb\u5236\u7f16\u7801\u7684\u590d\u6742\u673a\u5236&#xff0c;\u4e5f\u6ca1\u6709JSON\u5e93\u7684\u5c42\u5c42\u89e3\u6790\u3002HTTP\u7684\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316&#xff0c;\u5c31\u662f\u6700\u539f\u59cb\u7684\u5b57\u7b26\u4e32\u64cd\u4f5c&#xff0c;\u7b80\u5355\u3001\u76f4\u767d&#xff0c;\u4f46\u8db3\u591f\u7ba1\u7528\u3002<\/p>\n<h5 id=\"3.2%20HTTP%20%E5%93%8D%E5%BA%94%E7%9A%84%E6%A0%BC%E5%BC%8F\">3.2 HTTP\u54cd\u5e94\u62a5\u6587\u8be6\u89e3&#xff1a;\u670d\u52a1\u5668\u5982\u4f55\u8fd4\u56de\u7ed3\u679c<\/h5>\n<h6 id=\"3.2.1%20%E5%93%8D%E5%BA%94%E6%A0%BC%E5%BC%8F%E9%87%8C%E9%83%BD%E6%9C%89%E4%BB%80%E4%B9%88\">3.2.1 \u54cd\u5e94\u62a5\u6587\u7684\u57fa\u672c\u7ed3\u6784&#xff1a;\u72b6\u6001\u884c\u3001\u54cd\u5e94\u5934\u4e0e\u6d88\u606f\u4f53<\/h6>\n<p>\u62ff\u5230\u4e00\u4e2a HTTP \u54cd\u5e94\u62a5\u6587&#xff0c;\u7167\u6837\u62c6\u5f00\u770b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"948\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105055749-6aec1add5aa7a.png\" width=\"1659\" \/><\/p>\n<ul>\n<li>\n<p>\u9996\u884c&#xff1a;<span style=\"color:#fe2c24\">[\u7248\u672c\u53f7] &#043; [\u72b6\u6001\u7801] &#043; [\u72b6\u6001\u7801\u89e3\u91ca]<\/span>\u3002\u670d\u52a1\u5668\u4e00\u5f00\u53e3&#xff0c;\u5148\u62a5\u4e09\u4ef6\u4e8b&#xff1a;\u7528\u7684\u54ea\u4e2aHTTP\u7248\u672c\u3001\u8fd9\u6b21\u8bf7\u6c42\u7684\u7ed3\u679c\u662f\u51e0\u53f7\u72b6\u6001\u7801\u3001\u8fd9\u4e2a\u72b6\u6001\u7801\u53c8\u662f\u4ec0\u4e48\u610f\u601d\u3002<\/p>\n<\/li>\n<li>\n<p>Header&#xff1a;\u54cd\u5e94\u5934&#xff0c;\u4e00\u5806\u5192\u53f7\u5206\u5272\u7684\u952e\u503c\u5bf9\u3002\u6bcf\u7ec4\u4e4b\u95f4\u7528<span style=\"color:#fe2c24\">\\\\r\\\\n<\/span>\u9694\u5f00&#xff0c;\u78b0\u5230\u7a7a\u884c&#xff0c;Header\u90e8\u5206\u5c31\u6536\u5c3e\u4e86\u3002<\/p>\n<\/li>\n<li>\n<p>Body&#xff1a;\u7a7a\u884c\u540e\u9762\u7684\u5185\u5bb9&#xff0c;\u5168\u5f52Body\u3002Body\u5141\u8bb8\u662f\u7a7a\u5b57\u7b26\u4e32\u3002\u5982\u679cBody\u5b58\u5728&#xff0c;Header\u91cc\u4f1a\u6709\u4e00\u4e2aContent-Length\u5c5e\u6027&#xff0c;\u6807\u660e\u5b83\u6709\u591a\u957f\u3002\u670d\u52a1\u5668\u8981\u662f\u8fd4\u56de\u4e86\u4e00\u4e2aHTML\u9875\u9762&#xff0c;\u90a3\u9875\u9762\u7684\u5185\u5bb9&#xff0c;\u5c31\u5b89\u5b89\u9759\u9759\u8eba\u5728Body\u91cc\u3002<\/p>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"911\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105055751-6aec1adf0abc3.png\" width=\"1726\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"725\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105055752-6aec1ae054b59.png\" width=\"2170\" \/><\/p>\n<h4 id=\"%E5%9B%9B%E3%80%81%E8%AE%BE%E8%AE%A1%E4%B8%80%E4%B8%AA%E7%AE%80%E5%8D%95%E7%9A%84%20HTTP%20%E6%9C%8D%E5%8A%A1%E5%99%A8%E2%80%94%E2%80%94%E5%8F%82%E8%80%83%E6%BA%90%E7%A0%81\">\u56db\u3001HTTP\u670d\u52a1\u5668\u5b9e\u6218&#xff1a;\u4ece\u534f\u8bae\u89e3\u6790\u5230\u7f51\u9875\u8bbf\u95ee<\/h4>\n<p>\u4e0b\u9762\u628a\u4e00\u5957\u53ef\u76f4\u63a5\u7f16\u8bd1\u8fd0\u884c\u7684\u6781\u7b80HTTP\u670d\u52a1\u5668\u5b8c\u6574\u5199\u51fa\u6765\u3002\u4ee3\u7801\u6cbf\u7528\u4e4b\u524d\u7684Socket\u5c01\u88c5\u601d\u8def&#xff0c;\u91cd\u70b9\u653e\u5728HTTP\u8bf7\u6c42\u89e3\u6790 \u548cHTTP\u54cd\u5e94\u6784\u5efa\u4e0a\u3002<\/p>\n<h5 id=\"4.1%20Common.hpp%EF%BC%88%E9%94%99%E8%AF%AF%E7%A0%81%E4%B8%8E%E5%85%AC%E5%85%B1%E5%AE%9A%E4%B9%89%EF%BC%89\">4.1 Common.hpp&#xff08;\u9519\u8bef\u7801\u4e0e\u516c\u5171\u5b9a\u4e49&#xff09;<\/h5>\n<p>#pragma once<\/p>\n<p>#define SOCKET_ERR  1<br \/>\n#define BIND_ERR    2<br \/>\n#define LISTEN_ERR  3<br \/>\n#define ACCEPT_ERR  4 <\/p>\n<h5 id=\"4.2%20Log.hpp%EF%BC%88%E6%97%A5%E5%BF%97%EF%BC%89\">4.2 Log.hpp&#xff08;\u65e5\u5fd7&#xff09;<\/h5>\n<p>#pragma once<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;string&gt;<br \/>\n#include &lt;sstream&gt;<\/p>\n<p>namespace LogModule<br \/>\n{<br \/>\n    const std::string CAGE &#061; &#034;\\\\n&#034;;<\/p>\n<p>    enum class LEVEL<br \/>\n    {<br \/>\n        DEBUG,<br \/>\n        INFO,<br \/>\n        WARNING,<br \/>\n        ERROR,<br \/>\n        FATAL<br \/>\n    };<\/p>\n<p>    inline std::string LevelToString(LEVEL level)<br \/>\n    {<br \/>\n        switch (level)<br \/>\n        {<br \/>\n        case LEVEL::DEBUG:   return &#034;DEBUG&#034;;<br \/>\n        case LEVEL::INFO:    return &#034;INFO&#034;;<br \/>\n        case LEVEL::WARNING: return &#034;WARNING&#034;;<br \/>\n        case LEVEL::ERROR:   return &#034;ERROR&#034;;<br \/>\n        case LEVEL::FATAL:   return &#034;FATAL&#034;;<br \/>\n        default:             return &#034;UNKNOWN&#034;;<br \/>\n        }<br \/>\n    }<\/p>\n<p>    inline void Log(LEVEL level, const std::string &amp;msg)<br \/>\n    {<br \/>\n        std::cout &lt;&lt; &#034;[&#034; &lt;&lt; LevelToString(level) &lt;&lt; &#034;] &#034; &lt;&lt; msg &lt;&lt; CAGE;<br \/>\n    }<br \/>\n}<\/p>\n<p>#define LOG(level) LogModule::Log(level, std::string(__FILE__) &#043; &#034;:&#034; &#043; std::to_string(__LINE__) &#043; &#034; &#034;) <\/p>\n<h5 id=\"4.3%20InetAddr.hpp%EF%BC%88IP%20%E5%9C%B0%E5%9D%80%E5%B0%81%E8%A3%85%EF%BC%89\">4.3 InetAddr.hpp&#xff08;IP \u5730\u5740\u5c01\u88c5&#xff09;<\/h5>\n<p>#pragma once<\/p>\n<p>#include &lt;arpa\/inet.h&gt;<br \/>\n#include &lt;netinet\/in.h&gt;<br \/>\n#include &lt;sys\/socket.h&gt;<br \/>\n#include &lt;string&gt;<br \/>\n#include &lt;cstring&gt;<\/p>\n<p>namespace InetAddrModule<br \/>\n{<br \/>\n    class InetAddr<br \/>\n    {<br \/>\n    public:<br \/>\n        InetAddr(const struct sockaddr_in &amp;addr)<br \/>\n            : _addr(addr)<br \/>\n        {<br \/>\n            _port &#061; ntohs(_addr.sin_port);<br \/>\n            char ipbuffer[64];<br \/>\n            inet_ntop(AF_INET, &amp;_addr.sin_addr, ipbuffer, sizeof(ipbuffer));<br \/>\n            _ip &#061; ipbuffer;<br \/>\n        }<\/p>\n<p>        InetAddr(const std::string &amp;ip, uint16_t port)<br \/>\n            : _ip(ip), _port(port)<br \/>\n        {<br \/>\n            memset(&amp;_addr, 0, sizeof(_addr));<br \/>\n            _addr.sin_family &#061; AF_INET;<br \/>\n            _addr.sin_port &#061; htons(_port);<br \/>\n            inet_pton(AF_INET, _ip.c_str(), &amp;_addr.sin_addr);<br \/>\n        }<\/p>\n<p>        void SetAddr(const struct sockaddr_in &amp;addr)<br \/>\n        {<br \/>\n            _addr &#061; addr;<br \/>\n            _port &#061; ntohs(_addr.sin_port);<br \/>\n            char ipbuffer[64];<br \/>\n            inet_ntop(AF_INET, &amp;_addr.sin_addr, ipbuffer, sizeof(ipbuffer));<br \/>\n            _ip &#061; ipbuffer;<br \/>\n        }<\/p>\n<p>        std::string Ip() const { return _ip; }<br \/>\n        uint16_t Port() const { return _port; }<br \/>\n        struct sockaddr_in *GetSockaddrPtr() { return &amp;_addr; }<br \/>\n        socklen_t GetSockLine() const { return sizeof(_addr); }<\/p>\n<p>    private:<br \/>\n        struct sockaddr_in _addr;<br \/>\n        std::string _ip;<br \/>\n        uint16_t _port;<br \/>\n    };<br \/>\n} <\/p>\n<h5 id=\"4.4%20Socket.hpp%EF%BC%88Socket%20%E5%B0%81%E8%A3%85%EF%BC%89\">4.4 Socket.hpp&#xff08;Socket \u5c01\u88c5&#xff09;<\/h5>\n<p>#pragma once<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;string&gt;<br \/>\n#include &lt;memory&gt;<br \/>\n#include &lt;cstring&gt;<br \/>\n#include &lt;cstdlib&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;sys\/types.h&gt;<br \/>\n#include &lt;sys\/socket.h&gt;<br \/>\n#include &lt;netinet\/in.h&gt;<br \/>\n#include &lt;arpa\/inet.h&gt;<\/p>\n<p>#include &#034;Log.hpp&#034;<br \/>\n#include &#034;Common.hpp&#034;<br \/>\n#include &#034;InetAddr.hpp&#034;<\/p>\n<p>using namespace LogModule;<br \/>\nusing namespace InetAddrModule;<\/p>\n<p>namespace SocketModule<br \/>\n{<br \/>\n    const int DEFAULT_BACKLOG &#061; 128;<\/p>\n<p>    class TcpSocket<br \/>\n    {<br \/>\n    public:<br \/>\n        TcpSocket(int sockfd &#061; -1) : _sockfd(sockfd) {}<\/p>\n<p>        ~TcpSocket() {}<\/p>\n<p>        void CreateSocket()<br \/>\n        {<br \/>\n            _sockfd &#061; ::socket(AF_INET, SOCK_STREAM, 0);<br \/>\n            if (_sockfd &lt; 0)<br \/>\n            {<br \/>\n                LOG(LEVEL::FATAL) &lt;&lt; &#034;\u5957\u63a5\u5b57\u521b\u5efa\u5931\u8d25&#034;;<br \/>\n                exit(SOCKET_ERR);<br \/>\n            }<br \/>\n        }<\/p>\n<p>        bool BindSocket(InetAddr &amp;server)<br \/>\n        {<br \/>\n            int n &#061; ::bind(_sockfd, (struct sockaddr *)server.GetSockaddrPtr(),<br \/>\n                           server.GetSockLine());<br \/>\n            if (n &#061;&#061; -1)<br \/>\n            {<br \/>\n                LOG(LEVEL::FATAL) &lt;&lt; &#034;\u7ed1\u5b9a\u5957\u63a5\u5b57\u5931\u8d25&#034;;<br \/>\n                exit(BIND_ERR);<br \/>\n            }<br \/>\n            return true;<br \/>\n        }<\/p>\n<p>        bool ListenSocket(int backlog &#061; DEFAULT_BACKLOG)<br \/>\n        {<br \/>\n            int n &#061; ::listen(_sockfd, backlog);<br \/>\n            if (n &#061;&#061; -1)<br \/>\n            {<br \/>\n                LOG(LEVEL::FATAL) &lt;&lt; &#034;\u76d1\u542c\u5957\u63a5\u5b57\u5931\u8d25&#034;;<br \/>\n                exit(LISTEN_ERR);<br \/>\n            }<br \/>\n            return true;<br \/>\n        }<\/p>\n<p>        std::shared_ptr&lt;TcpSocket&gt; AcceptSocket(InetAddr &amp;client)<br \/>\n        {<br \/>\n            struct sockaddr_in peer;<br \/>\n            socklen_t len &#061; sizeof(peer);<br \/>\n            int sockfd &#061; ::accept(_sockfd, (struct sockaddr *)&amp;peer, &amp;len);<br \/>\n            if (sockfd &lt; 0)<br \/>\n            {<br \/>\n                LOG(LEVEL::ERROR) &lt;&lt; &#034;\u83b7\u53d6\u8fde\u63a5\u5931\u8d25&#034;;<br \/>\n                return nullptr;<br \/>\n            }<br \/>\n            client.SetAddr(peer);<br \/>\n            return std::make_shared&lt;TcpSocket&gt;(sockfd);<br \/>\n        }<\/p>\n<p>        int Recv(void *buf, size_t len)<br \/>\n        {<br \/>\n            return ::recv(_sockfd, buf, len, 0);<br \/>\n        }<\/p>\n<p>        int Send(const void *buf, size_t len)<br \/>\n        {<br \/>\n            return ::send(_sockfd, buf, len, 0);<br \/>\n        }<\/p>\n<p>        int GetSockFd() { return _sockfd; }<\/p>\n<p>        void Close()<br \/>\n        {<br \/>\n            if (_sockfd &gt;&#061; 0)<br \/>\n            {<br \/>\n                ::close(_sockfd);<br \/>\n                _sockfd &#061; -1;<br \/>\n            }<br \/>\n        }<\/p>\n<p>    private:<br \/>\n        int _sockfd;<br \/>\n    };<br \/>\n} <\/p>\n<h5 id=\"4.5%20HttpProtocol.hpp%EF%BC%88HTTP%20%E8%AF%B7%E6%B1%82%E8%A7%A3%E6%9E%90%E4%B8%8E%E5%93%8D%E5%BA%94%E6%9E%84%E5%BB%BA%EF%BC%89\">4.5 HttpProtocol.hpp&#xff08;HTTP \u8bf7\u6c42\u89e3\u6790\u4e0e\u54cd\u5e94\u6784\u5efa&#xff09;<\/h5>\n<p>\u8fd9\u662f\u6574\u4e2a\u670d\u52a1\u5668\u7684\u6838\u5fc3&#xff1a;\u89e3\u6790\u8bf7\u6c42\u3001\u6784\u5efa\u54cd\u5e94\u3002<\/p>\n<p>#pragma once<\/p>\n<p>#include &lt;string&gt;<br \/>\n#include &lt;sstream&gt;<br \/>\n#include &lt;unordered_map&gt;<br \/>\n#include &lt;vector&gt;<br \/>\n#include &lt;cctype&gt;<\/p>\n<p>namespace HttpModule<br \/>\n{<br \/>\n    \/\/ &#8212;&#8212;&#8212;- HTTP \u8bf7\u6c42\u7ed3\u6784 &#8212;&#8212;&#8212;-<br \/>\n    struct HttpRequest<br \/>\n    {<br \/>\n        std::string method;                          \/\/ GET \/ POST<br \/>\n        std::string url;                             \/\/ \u8d44\u6e90\u8def\u5f84<br \/>\n        std::string version;                         \/\/ HTTP\/1.0 \u6216 HTTP\/1.1<br \/>\n        std::unordered_map&lt;std::string, std::string&gt; headers;  \/\/ \u8bf7\u6c42\u5934<br \/>\n        std::string body;                            \/\/ \u8bf7\u6c42\u6b63\u6587<br \/>\n    };<\/p>\n<p>    \/\/ &#8212;&#8212;&#8212;- HTTP \u54cd\u5e94\u7ed3\u6784 &#8212;&#8212;&#8212;-<br \/>\n    struct HttpResponse<br \/>\n    {<br \/>\n        std::string version &#061; &#034;HTTP\/1.1&#034;;<br \/>\n        int status_code &#061; 200;<br \/>\n        std::string status_text &#061; &#034;OK&#034;;<br \/>\n        std::unordered_map&lt;std::string, std::string&gt; headers;<br \/>\n        std::string body;<br \/>\n    };<\/p>\n<p>    \/\/ &#8212;&#8212;&#8212;- \u5de5\u5177&#xff1a;\u53bb\u9996\u5c3e\u7a7a\u767d &#8212;&#8212;&#8212;-<br \/>\n    inline std::string Trim(const std::string &amp;s)<br \/>\n    {<br \/>\n        size_t begin &#061; 0;<br \/>\n        while (begin &lt; s.size() &amp;&amp; std::isspace(static_cast&lt;unsigned char&gt;(s[begin])))<br \/>\n        {<br \/>\n            &#043;&#043;begin;<br \/>\n        }<br \/>\n        size_t end &#061; s.size();<br \/>\n        while (end &gt; begin &amp;&amp; std::isspace(static_cast&lt;unsigned char&gt;(s[end &#8211; 1])))<br \/>\n        {<br \/>\n            &#8211;end;<br \/>\n        }<br \/>\n        return s.substr(begin, end &#8211; begin);<br \/>\n    }<\/p>\n<p>    \/\/ &#8212;&#8212;&#8212;- \u5de5\u5177&#xff1a;\u5b57\u7b26\u4e32\u8f6c\u5c0f\u5199 &#8212;&#8212;&#8212;-<br \/>\n    inline std::string ToLower(const std::string &amp;s)<br \/>\n    {<br \/>\n        std::string ret &#061; s;<br \/>\n        for (char &amp;c : ret)<br \/>\n        {<br \/>\n            c &#061; static_cast&lt;char&gt;(std::tolower(static_cast&lt;unsigned char&gt;(c)));<br \/>\n        }<br \/>\n        return ret;<br \/>\n    }<\/p>\n<p>    \/\/ &#8212;&#8212;&#8212;- \u5e8f\u5217\u5316&#xff1a;HttpResponse \u2192 \u5b57\u7b26\u4e32 &#8212;&#8212;&#8212;-<br \/>\n    inline std::string SerializeResponse(const HttpResponse &amp;resp)<br \/>\n    {<br \/>\n        std::ostringstream oss;<\/p>\n<p>        \/\/ 1. \u72b6\u6001\u884c<br \/>\n        oss &lt;&lt; resp.version &lt;&lt; &#034; &#034; &lt;&lt; resp.status_code &lt;&lt; &#034; &#034; &lt;&lt; resp.status_text &lt;&lt; &#034;\\\\r\\\\n&#034;;<\/p>\n<p>        \/\/ 2. \u54cd\u5e94\u5934<br \/>\n        for (const auto &amp;kv : resp.headers)<br \/>\n        {<br \/>\n            oss &lt;&lt; kv.first &lt;&lt; &#034;: &#034; &lt;&lt; kv.second &lt;&lt; &#034;\\\\r\\\\n&#034;;<br \/>\n        }<\/p>\n<p>        \/\/ 3. \u7a7a\u884c<br \/>\n        oss &lt;&lt; &#034;\\\\r\\\\n&#034;;<\/p>\n<p>        \/\/ 4. \u6b63\u6587<br \/>\n        oss &lt;&lt; resp.body;<\/p>\n<p>        return oss.str();<br \/>\n    }<\/p>\n<p>    \/\/ &#8212;&#8212;&#8212;- \u53cd\u5e8f\u5217\u5316&#xff1a;\u5b57\u7b26\u4e32 \u2192 HttpRequest &#8212;&#8212;&#8212;-<br \/>\n    \/\/ \u8fd4\u56de\u503c&#xff1a;true \u89e3\u6790\u6210\u529f&#xff1b;false \u89e3\u6790\u5931\u8d25<br \/>\n    inline bool DeserializeRequest(const std::string &amp;raw, HttpRequest &amp;req)<br \/>\n    {<br \/>\n        \/\/ 1. \u627e\u5230\u5934\u90e8\u4e0e\u6b63\u6587\u7684\u5206\u754c\u7a7a\u884c<br \/>\n        size_t pos &#061; raw.find(&#034;\\\\r\\\\n\\\\r\\\\n&#034;);<br \/>\n        std::string header_part;<br \/>\n        if (pos &#061;&#061; std::string::npos)<br \/>\n        {<br \/>\n            \/\/ \u6ca1\u6709\u7a7a\u884c&#xff0c;\u8bf4\u660e\u53ea\u6709\u5934\u90e8&#xff0c;\u6ca1\u6709\u6b63\u6587<br \/>\n            header_part &#061; raw;<br \/>\n            req.body.clear();<br \/>\n        }<br \/>\n        else<br \/>\n        {<br \/>\n            header_part &#061; raw.substr(0, pos);<br \/>\n            req.body &#061; raw.substr(pos &#043; 4);<br \/>\n        }<\/p>\n<p>        \/\/ 2. \u6309\u884c\u5207\u5206\u5934\u90e8<br \/>\n        std::istringstream iss(header_part);<br \/>\n        std::string line;<\/p>\n<p>        \/\/ 3. \u7b2c\u4e00\u884c&#xff1a;\u8bf7\u6c42\u884c<br \/>\n        if (!std::getline(iss, line))<br \/>\n        {<br \/>\n            return false;<br \/>\n        }<br \/>\n        if (!line.empty() &amp;&amp; line.back() &#061;&#061; &#039;\\\\r&#039;)<br \/>\n        {<br \/>\n            line.pop_back();<br \/>\n        }<\/p>\n<p>        std::istringstream line_ss(line);<br \/>\n        if (!(line_ss &gt;&gt; req.method &gt;&gt; req.url &gt;&gt; req.version))<br \/>\n        {<br \/>\n            return false;<br \/>\n        }<\/p>\n<p>        \/\/ 4. \u540e\u7eed\u884c&#xff1a;\u8bf7\u6c42\u5934<br \/>\n        while (std::getline(iss, line))<br \/>\n        {<br \/>\n            if (!line.empty() &amp;&amp; line.back() &#061;&#061; &#039;\\\\r&#039;)<br \/>\n            {<br \/>\n                line.pop_back();<br \/>\n            }<br \/>\n            if (line.empty())<br \/>\n            {<br \/>\n                continue;<br \/>\n            }<\/p>\n<p>            size_t colon &#061; line.find(&#039;:&#039;);<br \/>\n            if (colon &#061;&#061; std::string::npos)<br \/>\n            {<br \/>\n                continue;<br \/>\n            }<\/p>\n<p>            std::string key &#061; ToLower(Trim(line.substr(0, colon)));<br \/>\n            std::string value &#061; Trim(line.substr(colon &#043; 1));<br \/>\n            req.headers[key] &#061; value;<br \/>\n        }<\/p>\n<p>        return true;<br \/>\n    }<\/p>\n<p>    \/\/ &#8212;&#8212;&#8212;- \u5de5\u5177&#xff1a;\u6839\u636e\u72b6\u6001\u7801\u751f\u6210\u72b6\u6001\u6587\u672c &#8212;&#8212;&#8212;-<br \/>\n    inline std::string StatusText(int code)<br \/>\n    {<br \/>\n        switch (code)<br \/>\n        {<br \/>\n        case 200: return &#034;OK&#034;;<br \/>\n        case 404: return &#034;Not Found&#034;;<br \/>\n        case 400: return &#034;Bad Request&#034;;<br \/>\n        case 405: return &#034;Method Not Allowed&#034;;<br \/>\n        case 500: return &#034;Internal Server Error&#034;;<br \/>\n        default:  return &#034;Unknown&#034;;<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/\/ &#8212;&#8212;&#8212;- \u6784\u5efa\u54cd\u5e94 &#8212;&#8212;&#8212;-<br \/>\n    inline HttpResponse MakeResponse(int code, const std::string &amp;body,<br \/>\n                                     const std::string &amp;content_type &#061; &#034;text\/html; charset&#061;utf-8&#034;)<br \/>\n    {<br \/>\n        HttpResponse resp;<br \/>\n        resp.status_code &#061; code;<br \/>\n        resp.status_text &#061; StatusText(code);<br \/>\n        resp.headers[&#034;Content-Type&#034;] &#061; content_type;<br \/>\n        resp.headers[&#034;Content-Length&#034;] &#061; std::to_string(body.size());<br \/>\n        resp.headers[&#034;Connection&#034;] &#061; &#034;close&#034;;<br \/>\n        resp.body &#061; body;<br \/>\n        return resp;<br \/>\n    }<br \/>\n} <\/p>\n<h5 id=\"4.6%20HttpServer.hpp%EF%BC%88HTTP%20%E6%9C%8D%E5%8A%A1%E5%99%A8%EF%BC%89\">4.6 HttpServer.hpp&#xff08;HTTP \u670d\u52a1\u5668&#xff09;<\/h5>\n<p>#pragma once<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;string&gt;<br \/>\n#include &lt;memory&gt;<br \/>\n#include &lt;fstream&gt;<br \/>\n#include &lt;sstream&gt;<br \/>\n#include &lt;signal.h&gt;<br \/>\n#include &lt;sys\/wait.h&gt;<br \/>\n#include &lt;unistd.h&gt;<\/p>\n<p>#include &#034;Socket.hpp&#034;<br \/>\n#include &#034;HttpProtocol.hpp&#034;<\/p>\n<p>using namespace SocketModule;<br \/>\nusing namespace HttpModule;<\/p>\n<p>namespace ServerModule<br \/>\n{<br \/>\n    class HttpServer<br \/>\n    {<br \/>\n    public:<br \/>\n        HttpServer(uint16_t port &#061; 8080, const std::string &amp;webroot &#061; &#034;.&#034;)<br \/>\n            : _port(port), _webroot(webroot)<br \/>\n        {<br \/>\n        }<\/p>\n<p>        void Init()<br \/>\n        {<br \/>\n            InetAddr server(&#034;0.0.0.0&#034;, _port);<br \/>\n            _listensock &#061; std::make_shared&lt;TcpSocket&gt;();<br \/>\n            _listensock-&gt;CreateSocket();<\/p>\n<p>            \/\/ \u7aef\u53e3\u590d\u7528&#xff0c;\u907f\u514d\u91cd\u542f\u65f6 bind \u5931\u8d25<br \/>\n            int opt &#061; 1;<br \/>\n            setsockopt(_listensock-&gt;GetSockFd(), SOL_SOCKET, SO_REUSEADDR,<br \/>\n                       &amp;opt, sizeof(opt));<\/p>\n<p>            _listensock-&gt;BindSocket(server);<br \/>\n            _listensock-&gt;ListenSocket();<br \/>\n        }<\/p>\n<p>        void Start()<br \/>\n        {<br \/>\n            signal(SIGCHLD, SIG_IGN);<\/p>\n<p>            LOG(LEVEL::INFO) &lt;&lt; &#034;HTTP \u670d\u52a1\u5668\u542f\u52a8&#xff0c;\u7aef\u53e3&#xff1a;&#034; &#043; std::to_string(_port);<\/p>\n<p>            while (true)<br \/>\n            {<br \/>\n                InetAddr client;<br \/>\n                auto conn &#061; _listensock-&gt;AcceptSocket(client);<br \/>\n                if (!conn)<br \/>\n                {<br \/>\n                    continue;<br \/>\n                }<\/p>\n<p>                LOG(LEVEL::INFO) &lt;&lt; &#034;\u5ba2\u6237\u7aef\u8fde\u63a5&#xff1a;&#034; &#043; client.Ip() &#043; &#034;:&#034; &#043; std::to_string(client.Port());<\/p>\n<p>                pid_t id &#061; fork();<br \/>\n                if (id &#061;&#061; 0)<br \/>\n                {<br \/>\n                    _listensock-&gt;Close();<br \/>\n                    HandleConnection(conn);<br \/>\n                    conn-&gt;Close();<br \/>\n                    exit(0);<br \/>\n                }<\/p>\n<p>                conn-&gt;Close();<br \/>\n            }<br \/>\n        }<\/p>\n<p>    private:<br \/>\n        \/\/ \u5904\u7406\u5355\u4e2a HTTP \u8fde\u63a5<br \/>\n        void HandleConnection(std::shared_ptr&lt;TcpSocket&gt; conn)<br \/>\n        {<br \/>\n            std::string raw;<br \/>\n            char buf[4096];<\/p>\n<p>            \/\/ \u8bfb\u53d6\u8bf7\u6c42&#xff1a;\u7b80\u5355\u5904\u7406&#xff0c;\u8bfb\u4e00\u6b21\u6216\u591a\u6b21&#xff0c;\u76f4\u5230\u7f13\u51b2\u533a\u91cc\u51fa\u73b0 \\\\r\\\\n\\\\r\\\\n<br \/>\n            while (true)<br \/>\n            {<br \/>\n                int n &#061; conn-&gt;Recv(buf, sizeof(buf));<br \/>\n                if (n &lt;&#061; 0)<br \/>\n                {<br \/>\n                    return;<br \/>\n                }<\/p>\n<p>                raw.append(buf, n);<\/p>\n<p>                \/\/ \u5934\u90e8\u63a5\u6536\u5b8c\u6574\u540e&#xff0c;\u518d\u68c0\u67e5\u662f\u5426\u5df2\u6536\u5230 Content-Length \u6307\u5b9a\u7684\u6b63\u6587<br \/>\n                size_t head_end &#061; raw.find(&#034;\\\\r\\\\n\\\\r\\\\n&#034;);<br \/>\n                if (head_end !&#061; std::string::npos)<br \/>\n                {<br \/>\n                    HttpRequest tmp;<br \/>\n                    if (DeserializeRequest(raw, tmp))<br \/>\n                    {<br \/>\n                        size_t content_length &#061; 0;<br \/>\n                        auto it &#061; tmp.headers.find(&#034;content-length&#034;);<br \/>\n                        if (it !&#061; tmp.headers.end())<br \/>\n                        {<br \/>\n                            content_length &#061; static_cast&lt;size_t&gt;(std::stoul(it-&gt;second));<br \/>\n                        }<\/p>\n<p>                        size_t body_start &#061; head_end &#043; 4;<br \/>\n                        if (raw.size() &#8211; body_start &gt;&#061; content_length)<br \/>\n                        {<br \/>\n                            break;<br \/>\n                        }<br \/>\n                    }<br \/>\n                }<\/p>\n<p>                \/\/ \u9632\u6b62\u6076\u610f\u8bf7\u6c42\u628a\u7f13\u51b2\u533a\u6491\u7206<br \/>\n                if (raw.size() &gt; 1024 * 1024)<br \/>\n                {<br \/>\n                    return;<br \/>\n                }<br \/>\n            }<\/p>\n<p>            \/\/ \u89e3\u6790\u8bf7\u6c42<br \/>\n            HttpRequest req;<br \/>\n            if (!DeserializeRequest(raw, req))<br \/>\n            {<br \/>\n                std::string frame &#061; SerializeResponse(MakeResponse(400, &#034;&lt;h1&gt;400 Bad Request&lt;\/h1&gt;&#034;));<br \/>\n                conn-&gt;Send(frame.c_str(), frame.size());<br \/>\n                return;<br \/>\n            }<\/p>\n<p>            LOG(LEVEL::INFO) &lt;&lt; &#034;\u8bf7\u6c42&#xff1a;&#034; &#043; req.method &#043; &#034; &#034; &#043; req.url &#043; &#034; &#034; &#043; req.version;<\/p>\n<p>            \/\/ \u6784\u5efa\u54cd\u5e94<br \/>\n            HttpResponse resp &#061; Route(req);<\/p>\n<p>            \/\/ \u5e8f\u5217\u5316\u5e76\u53d1\u9001<br \/>\n            std::string frame &#061; SerializeResponse(resp);<br \/>\n            conn-&gt;Send(frame.c_str(), frame.size());<br \/>\n        }<\/p>\n<p>        \/\/ \u7b80\u5355\u7684\u8def\u7531&#xff1a;\u53ea\u5904\u7406 GET&#xff0c;\u5176\u4ed6\u65b9\u6cd5\u8fd4\u56de 405<br \/>\n        HttpResponse Route(const HttpRequest &amp;req)<br \/>\n        {<br \/>\n            if (req.method !&#061; &#034;GET&#034;)<br \/>\n            {<br \/>\n                return MakeResponse(405, &#034;&lt;h1&gt;405 Method Not Allowed&lt;\/h1&gt;&#034;);<br \/>\n            }<\/p>\n<p>            \/\/ \u6839\u8def\u5f84\u9ed8\u8ba4\u8fd4\u56de\u9996\u9875<br \/>\n            std::string path &#061; req.url;<br \/>\n            if (path &#061;&#061; &#034;\/&#034; || path.empty())<br \/>\n            {<br \/>\n                path &#061; &#034;\/index.html&#034;;<br \/>\n            }<\/p>\n<p>            \/\/ \u7b80\u5355\u7684\u8def\u5f84\u5b89\u5168\u6821\u9a8c&#xff0c;\u9632\u6b62 ..\/ \u76ee\u5f55\u7a7f\u8d8a<br \/>\n            if (path.find(&#034;..&#034;) !&#061; std::string::npos)<br \/>\n            {<br \/>\n                return MakeResponse(400, &#034;&lt;h1&gt;400 Bad Request&lt;\/h1&gt;&#034;);<br \/>\n            }<\/p>\n<p>            \/\/ \u62fc\u63a5\u672c\u5730\u6587\u4ef6\u8def\u5f84<br \/>\n            std::string filepath &#061; _webroot &#043; path;<\/p>\n<p>            std::ifstream ifs(filepath, std::ios::binary);<br \/>\n            if (!ifs.is_open())<br \/>\n            {<br \/>\n                return MakeResponse(404, &#034;&lt;h1&gt;404 Not Found&lt;\/h1&gt;&#034;);<br \/>\n            }<\/p>\n<p>            std::ostringstream oss;<br \/>\n            oss &lt;&lt; ifs.rdbuf();<br \/>\n            std::string body &#061; oss.str();<\/p>\n<p>            \/\/ \u6839\u636e\u540e\u7f00\u63a8\u65ad Content-Type<br \/>\n            std::string content_type &#061; GuessContentType(path);<\/p>\n<p>            return MakeResponse(200, body, content_type);<br \/>\n        }<\/p>\n<p>        std::string GuessContentType(const std::string &amp;path)<br \/>\n        {<br \/>\n            auto ends_with &#061; [&amp;](const std::string &amp;suffix) {<br \/>\n                return path.size() &gt;&#061; suffix.size() &amp;&amp;<br \/>\n                       path.compare(path.size() &#8211; suffix.size(), suffix.size(), suffix) &#061;&#061; 0;<br \/>\n            };<\/p>\n<p>            if (ends_with(&#034;.html&#034;) || ends_with(&#034;.htm&#034;)) return &#034;text\/html; charset&#061;utf-8&#034;;<br \/>\n            if (ends_with(&#034;.css&#034;))  return &#034;text\/css; charset&#061;utf-8&#034;;<br \/>\n            if (ends_with(&#034;.js&#034;))   return &#034;application\/javascript; charset&#061;utf-8&#034;;<br \/>\n            if (ends_with(&#034;.png&#034;))  return &#034;image\/png&#034;;<br \/>\n            if (ends_with(&#034;.jpg&#034;) || ends_with(&#034;.jpeg&#034;)) return &#034;image\/jpeg&#034;;<br \/>\n            if (ends_with(&#034;.gif&#034;))  return &#034;image\/gif&#034;;<br \/>\n            if (ends_with(&#034;.txt&#034;))  return &#034;text\/plain; charset&#061;utf-8&#034;;<br \/>\n            return &#034;application\/octet-stream&#034;;<br \/>\n        }<\/p>\n<p>    private:<br \/>\n        std::shared_ptr&lt;TcpSocket&gt; _listensock;<br \/>\n        uint16_t _port;<br \/>\n        std::string _webroot;   \/\/ Web \u6839\u76ee\u5f55<br \/>\n    };<br \/>\n} <\/p>\n<h5 id=\"4.7%20HttpServer.cc%EF%BC%88%E4%B8%BB%E7%A8%8B%E5%BA%8F%EF%BC%89\">4.7 HttpServer.cc&#xff08;\u4e3b\u7a0b\u5e8f&#xff09;<\/h5>\n<p>#include &#034;HttpServer.hpp&#034;<br \/>\n#include &lt;memory&gt;<\/p>\n<p>\/\/ \u7528\u6cd5&#xff1a;.\/http_server [\u7aef\u53e3\u53f7] [Web\u6839\u76ee\u5f55]<br \/>\nint main(int argc, char *argv[])<br \/>\n{<br \/>\n    uint16_t port &#061; 8080;<br \/>\n    std::string webroot &#061; &#034;.&#034;;<\/p>\n<p>    if (argc &gt;&#061; 2)<br \/>\n    {<br \/>\n        port &#061; static_cast&lt;uint16_t&gt;(std::stoi(argv[1]));<br \/>\n    }<br \/>\n    if (argc &gt;&#061; 3)<br \/>\n    {<br \/>\n        webroot &#061; argv[2];<br \/>\n    }<\/p>\n<p>    std::unique_ptr&lt;ServerModule::HttpServer&gt; server &#061;<br \/>\n        std::make_unique&lt;ServerModule::HttpServer&gt;(port, webroot);<\/p>\n<p>    server-&gt;Init();<br \/>\n    server-&gt;Start();<\/p>\n<p>    return 0;<br \/>\n} <\/p>\n<h5 id=\"4.8%20Makefile\">4.8 Makefile<\/h5>\n<p>.PHONY: all<br \/>\nall: http_server<\/p>\n<p>http_server: HttpServer.cc HttpServer.hpp Socket.hpp InetAddr.hpp HttpProtocol.hpp Common.hpp Log.hpp<br \/>\ng&#043;&#043; -o $&#064; $&lt; -std&#061;c&#043;&#043;17<\/p>\n<p>.PHONY: clean<br \/>\nclean:<br \/>\nrm -f http_server <\/p>\n<h5 id=\"4.9%20%E5%87%86%E5%A4%87%E4%B8%80%E4%B8%AA%E6%B5%8B%E8%AF%95%E9%A1%B5%E9%9D%A2\">4.9 \u51c6\u5907\u4e00\u4e2a\u6d4b\u8bd5\u9875\u9762<\/h5>\n<p>\u5728Web\u6839\u76ee\u5f55\u4e0b\u653e\u4e00\u4e2aindex.html&#xff1a;<\/p>\n<p>&lt;!DOCTYPE html&gt;<br \/>\n&lt;html&gt;<br \/>\n&lt;head&gt;<br \/>\n    &lt;meta charset&#061;&#034;utf-8&#034;&gt;<br \/>\n    &lt;title&gt;\u7b80\u6613HTTP\u670d\u52a1\u5668&lt;\/title&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;<br \/>\n    &lt;h1&gt;Hello, HTTP Server!&lt;\/h1&gt;<br \/>\n    &lt;p&gt;\u8fd9\u662f\u4e00\u4e2a\u6781\u7b80HTTP\u670d\u52a1\u5668\u8fd4\u56de\u7684\u9875\u9762\u3002&lt;\/p&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt; <\/p>\n<h5 id=\"4.10%20%E8%BF%90%E8%A1%8C%E4%B8%8E%E9%AA%8C%E8%AF%81\">4.10 \u8fd0\u884c\u4e0e\u9a8c\u8bc1<\/h5>\n<p>\u7f16\u8bd1&#xff1a;<\/p>\n<p>make<\/p>\n<p>\u542f\u52a8\u670d\u52a1\u5668&#xff0c;\u628a\u5f53\u524d\u76ee\u5f55\u4f5c\u4e3aWeb\u6839\u76ee\u5f55&#xff1a;<\/p>\n<p>.\/http_server 8080 .<\/p>\n<p>\u6d4f\u89c8\u5668\u8bbf\u95ee&#xff1a;<\/p>\n<p>http:\/\/127.0.0.1:8080\/<\/p>\n<p>\u6216\u8005\u7528curl\u9a8c\u8bc1&#xff1a;<\/p>\n<p>curl -v http:\/\/127.0.0.1:8080\/<\/p>\n<p>\u8f93\u51fa\u5927\u81f4\u5982\u4e0b&#xff1a;<\/p>\n<p>&lt; HTTP\/1.1 200 OK &lt; Content-Type: text\/html; charset&#061;utf-8 &lt; Content-Length: 245 &lt; Connection: close &lt; &lt;!DOCTYPE html&gt; &lt;html&gt; &#8230;<\/p>\n<hr \/>\n<p>\u5982\u679c\u8fd9\u7bc7\u6587\u7ae0\u5bf9\u4f60\u6709\u5e2e\u52a9&#xff0c;\u522b\u5fd8\u4e86\u70b9\u8d5e\u3001\u6536\u85cf\u3001\u5173\u6ce8\u4e09\u8fde\u652f\u6301\u3002\u4f60\u7684\u6bcf\u4e00\u6b21\u53cd\u9988&#xff0c;\u90fd\u662f\u6211\u7ee7\u7eed\u786c\u6838\u8f93\u51fa\u7684\u6700\u5927\u52a8\u529b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7b2c\u4e03\u671f\u6211\u4eec\u804a\u4e86\u600e\u4e48\u81ea\u5b9a\u4e49\u4e00\u4e2a\u5e94\u7528\u5c42\u534f\u8bae\u3002\u867d\u7136\u5634\u4e0a\u8bf4\u201c\u534f\u8bae\u662f\u7a0b\u5e8f\u5458\u81ea\u5df1\u5b9a\u7684\u201d&#xff0c;\u4f46\u73b0\u5b9e\u91cc&#xff0c;\u65e9\u6709\u4e00\u6279\u5927\u4f6c\u628a\u597d\u7528\u7684\u5e94\u7528\u5c42\u534f\u8bae\u5b9a\u4e49\u597d\u4e86&#xff0c;\u6446\u5728\u90a3\u513f\u4f9b\u6211\u4eec\u76f4\u63a5\u53c2\u8003\u3001\u76f4\u63a5\u4f7f\u7528\u3002HTTP&#xff08;\u8d85\u6587\u672c\u4f20\u8f93\u534f\u8bae&#xff09;&#xff0c;\u5c31\u662f\u5176\u4e2d\u6700\u7ecf\u5178\u7684\u4e00\u4e2a\u3002<br \/>\n\u4ece\u672c\u6587\u5f00\u59cb&#xff0c;\u8fde\u7eed\u591a\u7bc7\u5185\u5bb9&#xff0c;\u6211\u4eec\u5c31\u628aHTTP\u534f\u8bae\u63b0\u5f00\u63c9\u788e&#xff0c;\u597d\u597d\u8bb2\u4e00\u8bb2\u3002<br \/>\n\u76ee\u5f55<br \/>\n\u4e00\u3001\u521d\u8bc6HTTP&#xff1a;\u7406\u89e3Web\u901a\u4fe1\u7684\u57fa\u672c\u534f\u8bae <\/p>\n","protected":false},"author":2,"featured_media":122700,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,151,190,43,211],"topic":[],"class_list":["post-122713","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-c","tag-http","tag-190","tag-43","tag-211"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4ece\u96f6\u5165\u95e8\u8ba1\u7b97\u673a\u7f51\u7edc\u7cfb\u5217\uff08\u4e5d\uff09\uff1aHTTP\u534f\u8bae\u8be6\u89e3\u2014\u2014\u4eceURL\u89e3\u6790\u5230\u8bf7\u6c42\u54cd\u5e94\u4e0e\u670d\u52a1\u5668\u5b9e\u6218 - \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\/122713.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4ece\u96f6\u5165\u95e8\u8ba1\u7b97\u673a\u7f51\u7edc\u7cfb\u5217\uff08\u4e5d\uff09\uff1aHTTP\u534f\u8bae\u8be6\u89e3\u2014\u2014\u4eceURL\u89e3\u6790\u5230\u8bf7\u6c42\u54cd\u5e94\u4e0e\u670d\u52a1\u5668\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u7b2c\u4e03\u671f\u6211\u4eec\u804a\u4e86\u600e\u4e48\u81ea\u5b9a\u4e49\u4e00\u4e2a\u5e94\u7528\u5c42\u534f\u8bae\u3002\u867d\u7136\u5634\u4e0a\u8bf4\u201c\u534f\u8bae\u662f\u7a0b\u5e8f\u5458\u81ea\u5df1\u5b9a\u7684\u201d&#xff0c;\u4f46\u73b0\u5b9e\u91cc&#xff0c;\u65e9\u6709\u4e00\u6279\u5927\u4f6c\u628a\u597d\u7528\u7684\u5e94\u7528\u5c42\u534f\u8bae\u5b9a\u4e49\u597d\u4e86&#xff0c;\u6446\u5728\u90a3\u513f\u4f9b\u6211\u4eec\u76f4\u63a5\u53c2\u8003\u3001\u76f4\u63a5\u4f7f\u7528\u3002HTTP&#xff08;\u8d85\u6587\u672c\u4f20\u8f93\u534f\u8bae&#xff09;&#xff0c;\u5c31\u662f\u5176\u4e2d\u6700\u7ecf\u5178\u7684\u4e00\u4e2a\u3002 \u4ece\u672c\u6587\u5f00\u59cb&#xff0c;\u8fde\u7eed\u591a\u7bc7\u5185\u5bb9&#xff0c;\u6211\u4eec\u5c31\u628aHTTP\u534f\u8bae\u63b0\u5f00\u63c9\u788e&#xff0c;\u597d\u597d\u8bb2\u4e00\u8bb2\u3002 \u76ee\u5f55 \u4e00\u3001\u521d\u8bc6HTTP&#xff1a;\u7406\u89e3Web\u901a\u4fe1\u7684\u57fa\u672c\u534f\u8bae\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/122713.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-05T05:57:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105055746-6aec1ada94fe1.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=\"13 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/122713.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/122713.html\",\"name\":\"\u4ece\u96f6\u5165\u95e8\u8ba1\u7b97\u673a\u7f51\u7edc\u7cfb\u5217\uff08\u4e5d\uff09\uff1aHTTP\u534f\u8bae\u8be6\u89e3\u2014\u2014\u4eceURL\u89e3\u6790\u5230\u8bf7\u6c42\u54cd\u5e94\u4e0e\u670d\u52a1\u5668\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-05T05:57:54+00:00\",\"dateModified\":\"2026-11-05T05:57:54+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/122713.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/122713.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/122713.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4ece\u96f6\u5165\u95e8\u8ba1\u7b97\u673a\u7f51\u7edc\u7cfb\u5217\uff08\u4e5d\uff09\uff1aHTTP\u534f\u8bae\u8be6\u89e3\u2014\u2014\u4eceURL\u89e3\u6790\u5230\u8bf7\u6c42\u54cd\u5e94\u4e0e\u670d\u52a1\u5668\u5b9e\u6218\"}]},{\"@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":"\u4ece\u96f6\u5165\u95e8\u8ba1\u7b97\u673a\u7f51\u7edc\u7cfb\u5217\uff08\u4e5d\uff09\uff1aHTTP\u534f\u8bae\u8be6\u89e3\u2014\u2014\u4eceURL\u89e3\u6790\u5230\u8bf7\u6c42\u54cd\u5e94\u4e0e\u670d\u52a1\u5668\u5b9e\u6218 - \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\/122713.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4ece\u96f6\u5165\u95e8\u8ba1\u7b97\u673a\u7f51\u7edc\u7cfb\u5217\uff08\u4e5d\uff09\uff1aHTTP\u534f\u8bae\u8be6\u89e3\u2014\u2014\u4eceURL\u89e3\u6790\u5230\u8bf7\u6c42\u54cd\u5e94\u4e0e\u670d\u52a1\u5668\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u7b2c\u4e03\u671f\u6211\u4eec\u804a\u4e86\u600e\u4e48\u81ea\u5b9a\u4e49\u4e00\u4e2a\u5e94\u7528\u5c42\u534f\u8bae\u3002\u867d\u7136\u5634\u4e0a\u8bf4\u201c\u534f\u8bae\u662f\u7a0b\u5e8f\u5458\u81ea\u5df1\u5b9a\u7684\u201d&#xff0c;\u4f46\u73b0\u5b9e\u91cc&#xff0c;\u65e9\u6709\u4e00\u6279\u5927\u4f6c\u628a\u597d\u7528\u7684\u5e94\u7528\u5c42\u534f\u8bae\u5b9a\u4e49\u597d\u4e86&#xff0c;\u6446\u5728\u90a3\u513f\u4f9b\u6211\u4eec\u76f4\u63a5\u53c2\u8003\u3001\u76f4\u63a5\u4f7f\u7528\u3002HTTP&#xff08;\u8d85\u6587\u672c\u4f20\u8f93\u534f\u8bae&#xff09;&#xff0c;\u5c31\u662f\u5176\u4e2d\u6700\u7ecf\u5178\u7684\u4e00\u4e2a\u3002 \u4ece\u672c\u6587\u5f00\u59cb&#xff0c;\u8fde\u7eed\u591a\u7bc7\u5185\u5bb9&#xff0c;\u6211\u4eec\u5c31\u628aHTTP\u534f\u8bae\u63b0\u5f00\u63c9\u788e&#xff0c;\u597d\u597d\u8bb2\u4e00\u8bb2\u3002 \u76ee\u5f55 \u4e00\u3001\u521d\u8bc6HTTP&#xff1a;\u7406\u89e3Web\u901a\u4fe1\u7684\u57fa\u672c\u534f\u8bae","og_url":"https:\/\/www.wsisp.com\/helps\/122713.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-05T05:57:54+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261105055746-6aec1ada94fe1.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"13 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/122713.html","url":"https:\/\/www.wsisp.com\/helps\/122713.html","name":"\u4ece\u96f6\u5165\u95e8\u8ba1\u7b97\u673a\u7f51\u7edc\u7cfb\u5217\uff08\u4e5d\uff09\uff1aHTTP\u534f\u8bae\u8be6\u89e3\u2014\u2014\u4eceURL\u89e3\u6790\u5230\u8bf7\u6c42\u54cd\u5e94\u4e0e\u670d\u52a1\u5668\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-05T05:57:54+00:00","dateModified":"2026-11-05T05:57:54+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/122713.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/122713.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/122713.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4ece\u96f6\u5165\u95e8\u8ba1\u7b97\u673a\u7f51\u7edc\u7cfb\u5217\uff08\u4e5d\uff09\uff1aHTTP\u534f\u8bae\u8be6\u89e3\u2014\u2014\u4eceURL\u89e3\u6790\u5230\u8bf7\u6c42\u54cd\u5e94\u4e0e\u670d\u52a1\u5668\u5b9e\u6218"}]},{"@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\/122713","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=122713"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/122713\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/122700"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=122713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=122713"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=122713"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=122713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}