{"id":10904,"date":"2025-04-18T18:18:24","date_gmt":"2025-04-18T10:18:24","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/10904.html"},"modified":"2025-04-18T18:18:24","modified_gmt":"2025-04-18T10:18:24","slug":"%e5%9f%ba%e4%ba%8e-boost-asio-%e5%92%8c-boost-beast-%e7%9a%84%e5%bc%82%e6%ad%a5-http-%e6%9c%8d%e5%8a%a1%e5%99%a8%ef%bc%88%e5%ad%a6%e4%b9%a0%e8%ae%b0%e5%bd%95%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/10904.html","title":{"rendered":"\u57fa\u4e8e Boost.Asio \u548c Boost.Beast \u7684\u5f02\u6b65 HTTP \u670d\u52a1\u5668\uff08\u5b66\u4e60\u8bb0\u5f55\uff09"},"content":{"rendered":"<p>\u5df2\u5b8c\u6210\u529f\u80fd&#xff1a;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u652f\u6301 GET \u548c POST \u8bf7\u6c42\u7684\u8def\u7531\u4e0e\u56de\u8c03\u5904\u7406\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u89e3\u6790URL\u8bf7\u6c42\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5355\u4f8b\u6a21\u5f0f \u7ba1\u7406\u6838\u5fc3\u4e1a\u52a1\u903b\u8f91\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5f02\u6b65 I\/O \u6280\u672f\u548c \u5b9a\u65f6\u5668 \u63a7\u5236\u8d85\u65f6\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u901a\u8fc7\u56de\u8c03\u51fd\u6570\u6ce8\u518c\u673a\u5236&#xff0c;\u53ef\u4ee5\u7075\u6d3b\u5730\u4e3a\u4e0d\u540c\u7684 URL \u8def\u7531\u6ce8\u518c\u5904\u7406\u51fd\u6570\u3002<\/p>\n<h3>1. \u9879\u76ee\u80cc\u666f<\/h3>\n<h4>1.1 \u9879\u76ee\u7b80\u4ecb<\/h4>\n<p>\u672c\u9879\u76ee\u662f\u4e00\u4e2a\u57fa\u4e8e Boost.Asio \u548c Boost.Beast \u7684\u9ad8\u6027\u80fd HTTP \u670d\u52a1\u5668&#xff0c;\u5b9e\u73b0\u4e86\u5bf9 HTTP \u8bf7\u6c42\u7684\u5904\u7406\u3001\u8def\u7531\u529f\u80fd\u548c\u56de\u8c03\u673a\u5236\u3002\u8be5\u670d\u52a1\u5668\u4f7f\u7528 \u5355\u4f8b\u6a21\u5f0f \u6765\u7ba1\u7406\u8bf7\u6c42\u903b\u8f91&#xff0c;\u5e76\u91c7\u7528 \u5f02\u6b65 I\/O \u6280\u672f \u6765\u63d0\u5347\u5e76\u53d1\u5904\u7406\u80fd\u529b\u3002\u652f\u6301\u7684 HTTP \u8bf7\u6c42\u7c7b\u578b\u5305\u62ec GET \u548c POST&#xff0c;\u5e76\u80fd\u591f\u6839\u636e URL \u6ce8\u518c\u4e0d\u540c\u7684\u5904\u7406\u51fd\u6570&#xff0c;\u4ece\u800c\u5b9e\u73b0\u7075\u6d3b\u7684\u8bf7\u6c42\u8def\u7531\u4e0e\u56de\u8c03\u5904\u7406\u673a\u5236\u3002<\/p>\n<h4>1.2 \u9879\u76ee\u76ee\u6807<\/h4>\n<p>\u8be5\u9879\u76ee\u65e8\u5728\u63d0\u4f9b\u4e00\u4e2a \u9ad8\u6548\u3001\u53ef\u6269\u5c55 \u7684 HTTP \u670d\u52a1\u5668&#xff0c;\u9002\u7528\u4e8e\u5904\u7406\u5927\u91cf\u5e76\u53d1 HTTP \u8bf7\u6c42&#xff0c;\u5177\u5907\u4ee5\u4e0b\u6838\u5fc3\u76ee\u6807&#xff1a;<\/p>\n<ul>\n<li>\u9ad8\u5e76\u53d1\u5904\u7406\u80fd\u529b&#xff1a;\u901a\u8fc7\u4f7f\u7528\u5f02\u6b65 I\/O \u548c\u975e\u963b\u585e I\/O \u64cd\u4f5c\u663e\u8457\u63d0\u5347\u5e76\u53d1\u5904\u7406\u80fd\u529b&#xff0c;\u907f\u514d\u56e0\u540c\u6b65\u963b\u585e\u5bfc\u81f4\u7684\u6027\u80fd\u74f6\u9888\u3002<\/li>\n<li>\u53ef\u6269\u5c55\u6027&#xff1a;\u652f\u6301\u901a\u8fc7\u6ce8\u518c\u56de\u8c03\u51fd\u6570\u6765\u7075\u6d3b\u5904\u7406\u4e0d\u540c\u7684 HTTP \u8bf7\u6c42&#xff0c;\u80fd\u591f\u6839\u636e\u9700\u8981\u6269\u5c55\u652f\u6301\u66f4\u591a\u7684 HTTP \u8bf7\u6c42\u7c7b\u578b\u548c\u81ea\u5b9a\u4e49\u4e1a\u52a1\u903b\u8f91\u3002<\/li>\n<li>\u7b80\u6d01\u7684\u5355\u4f8b\u7ba1\u7406&#xff1a;\u4f7f\u7528\u5355\u4f8b\u6a21\u5f0f\u7ba1\u7406\u5168\u5c40\u8d44\u6e90&#xff0c;\u786e\u4fdd\u53ea\u6709\u4e00\u4e2a\u670d\u52a1\u5668\u5b9e\u4f8b\u548c\u552f\u4e00\u7684\u8bf7\u6c42\u903b\u8f91\u5904\u7406\u5b9e\u4f8b&#xff0c;\u907f\u514d\u91cd\u590d\u521d\u59cb\u5316\u8d44\u6e90\u548c\u7ba1\u7406\u591a\u4e2a\u5b9e\u4f8b\u7684\u95ee\u9898\u3002<\/li>\n<li>\u8d85\u65f6\u7ba1\u7406&#xff1a;\u901a\u8fc7 Boost.Asio \u63d0\u4f9b\u7684\u5b9a\u65f6\u5668\u673a\u5236\u5b9e\u73b0 HTTP \u8fde\u63a5\u7684\u8d85\u65f6\u63a7\u5236&#xff0c;\u786e\u4fdd\u670d\u52a1\u5668\u80fd\u591f\u53ca\u65f6\u5173\u95ed\u4e0d\u6d3b\u8dc3\u7684\u8fde\u63a5&#xff0c;\u907f\u514d\u56e0\u8fde\u63a5\u6cc4\u6f0f\u5bfc\u81f4\u7684\u8d44\u6e90\u6d6a\u8d39\u3002<\/li>\n<\/ul>\n<h3>2. \u9879\u76ee\u67b6\u6784<\/h3>\n<h4>2.1 \u67b6\u6784\u6982\u8ff0<\/h4>\n<p>\u672c\u9879\u76ee\u91c7\u7528\u4e86\u4e8b\u4ef6\u9a71\u52a8\u7684\u67b6\u6784\u6a21\u578b&#xff0c;\u57fa\u4e8e Boost.Asio \u63d0\u4f9b\u7684\u5f02\u6b65 I\/O \u529f\u80fd\u5b9e\u73b0\u9ad8\u6548\u7684\u8bf7\u6c42\u5904\u7406\u3002\u6574\u4e2a\u7cfb\u7edf\u901a\u8fc7 CServer \u542f\u52a8\u5e76\u63a5\u53d7\u5ba2\u6237\u7aef\u7684\u8fde\u63a5&#xff0c;HttpConnection \u7ba1\u7406\u6bcf\u4e2a HTTP \u8bf7\u6c42\u7684\u8fde\u63a5&#xff0c;LogicSystem \u5904\u7406\u8bf7\u6c42\u7684\u4e1a\u52a1\u903b\u8f91&#xff0c;\u5229\u7528 \u5355\u4f8b\u6a21\u5f0f \u786e\u4fdd\u8bf7\u6c42\u5904\u7406\u903b\u8f91\u7684\u552f\u4e00\u6027\u3002\u5404\u4e2a\u6a21\u5757\u534f\u540c\u5de5\u4f5c&#xff0c;\u901a\u8fc7\u56de\u8c03\u673a\u5236\u5bf9\u8bf7\u6c42\u8fdb\u884c\u5904\u7406\u3002<\/p>\n<p>\u670d\u52a1\u5668\u67b6\u6784\u53ef\u4ee5\u5206\u4e3a\u4ee5\u4e0b\u51e0\u4e2a\u5173\u952e\u6a21\u5757&#xff1a;<\/p>\n<ul>\n<li>CServer&#xff1a;\u8d1f\u8d23\u542f\u52a8\u670d\u52a1\u5668&#xff0c;\u76d1\u542c\u6307\u5b9a\u7aef\u53e3\u5e76\u63a5\u53d7\u5ba2\u6237\u7aef\u8fde\u63a5\u8bf7\u6c42\u3002<\/li>\n<li>LogicSystem&#xff1a;\u4f7f\u7528\u5355\u4f8b\u6a21\u5f0f\u7ba1\u7406 HTTP \u8bf7\u6c42\u7684\u903b\u8f91\u5904\u7406&#xff0c;\u8d1f\u8d23\u8def\u7531\u6ce8\u518c\u4e0e\u56de\u8c03\u51fd\u6570\u7684\u6267\u884c\u3002<\/li>\n<li>HttpConnection&#xff1a;\u5904\u7406\u6bcf\u4e2a HTTP \u8bf7\u6c42\u7684\u8fde\u63a5&#xff0c;\u5305\u62ec\u8bf7\u6c42\u89e3\u6790\u3001\u54cd\u5e94\u6784\u5efa\u4ee5\u53ca\u8fde\u63a5\u8d85\u65f6\u7ba1\u7406\u3002<\/li>\n<li>Singleton&#xff1a;\u4e00\u4e2a\u6a21\u677f\u7c7b&#xff0c;\u63d0\u4f9b\u5355\u4f8b\u6a21\u5f0f\u7684\u5b9e\u73b0&#xff0c;\u786e\u4fdd\u7cfb\u7edf\u4e2d\u903b\u8f91\u5904\u7406\u7cfb\u7edf\u548c\u5176\u4ed6\u6838\u5fc3\u7ec4\u4ef6\u53ea\u6709\u4e00\u4e2a\u5b9e\u4f8b\u3002<\/li>\n<li>\u56de\u8c03\u51fd\u6570&#xff1a;\u901a\u8fc7\u56de\u8c03\u51fd\u6570\u7c7b\u578b HttpHandler \u5904\u7406 HTTP \u8bf7\u6c42&#xff0c;\u652f\u6301 GET \u548c POST \u8bf7\u6c42\u7684\u7075\u6d3b\u5904\u7406\u3002<\/li>\n<\/ul>\n<h4>2.2 \u6a21\u5757\u5212\u5206<\/h4>\n<h5>1.\u7f51\u7edc\u901a\u4fe1\u6a21\u5757<\/h5>\n<p>\u8be5\u6a21\u5757\u57fa\u4e8e Boost.Asio \u5e93\u5b9e\u73b0&#xff0c;\u7528\u4e8e\u7ba1\u7406\u5f02\u6b65\u7684 TCP \u8fde\u63a5\u548c HTTP \u8bf7\u6c42\u7684\u5904\u7406\u3002CServer \u8d1f\u8d23\u76d1\u542c\u7aef\u53e3\u5e76\u63a5\u53d7\u5ba2\u6237\u7aef\u8fde\u63a5&#xff0c;HttpConnection \u8d1f\u8d23\u5904\u7406\u6bcf\u4e2a\u8fde\u63a5\u7684 HTTP \u8bf7\u6c42&#xff0c;\u91c7\u7528\u975e\u963b\u585e I\/O \u64cd\u4f5c\u6765\u4fdd\u8bc1\u670d\u52a1\u5668\u7684\u9ad8\u6548\u6027\u80fd\u3002<\/p>\n<p>\u5173\u952e\u7c7b&#xff1a;<\/p>\n<ul>\n<li>CServer&#xff1a;\u8d1f\u8d23\u521b\u5efa acceptor \u5e76\u7b49\u5f85\u8fde\u63a5&#xff0c;\u7ba1\u7406 tcp::socket\u3002<\/li>\n<li>HttpConnection&#xff1a;\u8d1f\u8d23\u5904\u7406 HTTP \u8bf7\u6c42\u548c\u54cd\u5e94&#xff0c;\u7ba1\u7406 TCP \u8fde\u63a5\u3002<\/li>\n<\/ul>\n<h5>2.HTTP \u8bf7\u6c42\u5904\u7406\u6a21\u5757<\/h5>\n<p>\u8be5\u6a21\u5757\u57fa\u4e8e Boost.Beast \u5b9e\u73b0&#xff0c;\u8d1f\u8d23\u89e3\u6790 HTTP \u8bf7\u6c42\u548c\u6784\u5efa HTTP \u54cd\u5e94\u3002\u4f7f\u7528 http::request \u548c http::response \u7c7b\u578b\u6765\u5904\u7406\u8bf7\u6c42\u548c\u54cd\u5e94\u5185\u5bb9\u3002\u8be5\u6a21\u5757\u8fd8\u901a\u8fc7\u56de\u8c03\u51fd\u6570 HttpHandler \u8fdb\u884c\u8def\u7531\u5904\u7406\u3002<\/p>\n<p>\u5173\u952e\u7c7b&#xff1a;<\/p>\n<ul>\n<li>HttpConnection&#xff1a;\u89e3\u6790\u8bf7\u6c42\u5e76\u6784\u5efa\u54cd\u5e94\u3002<\/li>\n<li>LogicSystem&#xff1a;\u6ce8\u518c\u5e76\u8c03\u7528\u5904\u7406 GET\/POST \u8bf7\u6c42\u7684\u56de\u8c03\u51fd\u6570\u3002<\/li>\n<\/ul>\n<h5>3.\u5355\u4f8b\u6a21\u5f0f\u6a21\u5757<\/h5>\n<p>\u901a\u8fc7\u6a21\u677f\u5b9e\u73b0\u7684 Singleton \u7c7b&#xff0c;\u786e\u4fdd\u4e86\u7cfb\u7edf\u4e2d LogicSystem \u7c7b\u7b49\u91cd\u8981\u7ec4\u4ef6\u7684\u552f\u4e00\u6027\u3002\u5b83\u901a\u8fc7\u61d2\u6c49\u5f0f\u5355\u4f8b\u6a21\u5f0f\u6765\u5ef6\u8fdf\u521d\u59cb\u5316&#xff0c;\u907f\u514d\u4e86\u4e0d\u5fc5\u8981\u7684\u8d44\u6e90\u6d6a\u8d39&#xff0c;\u786e\u4fdd\u7cfb\u7edf\u7684\u9ad8\u6548\u8fd0\u884c\u3002<\/p>\n<p>\u5173\u952e\u7c7b&#xff1a;<\/p>\n<ul>\n<li>Singleton&#xff1a;\u6a21\u677f\u7c7b&#xff0c;\u7528\u4e8e\u5b9e\u73b0 LogicSystem \u7b49\u6838\u5fc3\u7ec4\u4ef6\u7684\u5355\u4f8b\u6a21\u5f0f\u3002<\/li>\n<\/ul>\n<h5>4.\u8d85\u65f6\u7ba1\u7406\u6a21\u5757<\/h5>\n<p>Boost.Asio \u7684 steady_timer \u88ab\u7528\u4e8e\u5904\u7406\u8fde\u63a5\u8d85\u65f6\u3002\u6bcf\u4e2a HTTP \u8fde\u63a5\u90fd\u914d\u5907\u4e86\u4e00\u4e2a\u5b9a\u65f6\u5668&#xff0c;\u5982\u679c\u8fde\u63a5\u5728\u89c4\u5b9a\u65f6\u95f4\u5185\u6ca1\u6709\u6536\u5230\u6709\u6548\u54cd\u5e94&#xff0c;\u5219\u4f1a\u81ea\u52a8\u5173\u95ed\u8fde\u63a5&#xff0c;\u9632\u6b62\u8d44\u6e90\u6cc4\u6f0f\u3002<\/p>\n<p>\u5173\u952e\u7c7b&#xff1a;<\/p>\n<ul>\n<li>HttpConnection&#xff1a;\u5185\u90e8\u6301\u6709\u4e00\u4e2a steady_timer&#xff0c;\u7528\u4e8e\u5904\u7406\u6bcf\u4e2a\u8fde\u63a5\u7684\u8d85\u65f6\u3002<\/li>\n<\/ul>\n<h4>2.3 \u6570\u636e\u6d41<\/h4>\n<p>\u9879\u76ee\u7684\u6570\u636e\u6d41\u8fc7\u7a0b\u5982\u4e0b&#xff1a;<\/p>\n<li>CServer \u542f\u52a8\u5e76\u76d1\u542c\u6307\u5b9a\u7aef\u53e3&#xff0c;\u7b49\u5f85\u6765\u81ea\u5ba2\u6237\u7aef\u7684 TCP \u8fde\u63a5\u3002<\/li>\n<li>\u5ba2\u6237\u7aef\u8fde\u63a5\u8bf7\u6c42\u5230\u6765\u65f6&#xff0c;CServer \u4f7f\u7528 acceptor \u63a5\u53d7\u8fde\u63a5&#xff0c;\u5e76\u4e3a\u6bcf\u4e2a\u8fde\u63a5\u521b\u5efa\u4e00\u4e2a HttpConnection \u5b9e\u4f8b\u3002<\/li>\n<li>HttpConnection \u542f\u52a8\u5f02\u6b65\u8bfb\u53d6\u64cd\u4f5c&#xff0c;\u63a5\u6536\u5ba2\u6237\u7aef\u53d1\u9001\u7684 HTTP \u8bf7\u6c42&#xff0c;\u5e76\u5c06\u8bf7\u6c42\u6570\u636e\u5b58\u50a8\u5728 beast::flat_buffer \u4e2d\u3002<\/li>\n<li>\u5728\u63a5\u6536\u5230\u5b8c\u6574\u7684 HTTP \u8bf7\u6c42\u540e&#xff0c;HttpConnection \u4f1a\u89e3\u6790\u8bf7\u6c42&#xff0c;\u63d0\u53d6 URL \u548c\u8bf7\u6c42\u65b9\u6cd5&#xff08;\u5982 GET \u6216 POST&#xff09;\u3002<\/li>\n<li>HttpConnection \u5c06\u8bf7\u6c42\u8f6c\u4ea4\u7ed9 LogicSystem&#xff0c;LogicSystem \u6839\u636e\u8bf7\u6c42\u7684 URL \u67e5\u627e\u5bf9\u5e94\u7684\u56de\u8c03\u51fd\u6570&#xff08;HttpHandler&#xff09;&#xff0c;\u5e76\u6267\u884c\u8be5\u56de\u8c03\u51fd\u6570\u8fdb\u884c\u5904\u7406\u3002<\/li>\n<li>\u56de\u8c03\u51fd\u6570\u5904\u7406\u5b8c\u8bf7\u6c42\u540e&#xff0c;HttpConnection \u5c06\u751f\u6210\u76f8\u5e94\u7684 HTTP \u54cd\u5e94&#xff0c;\u5e76\u5f02\u6b65\u5c06\u54cd\u5e94\u6570\u636e\u53d1\u9001\u56de\u5ba2\u6237\u7aef\u3002<\/li>\n<li>\u5982\u679c\u8fde\u63a5\u5728\u89c4\u5b9a\u65f6\u95f4\u5185\u672a\u5b8c\u6210\u5904\u7406&#xff0c;HttpConnection \u4f1a\u89e6\u53d1\u5b9a\u65f6\u5668&#xff0c;\u4e3b\u52a8\u5173\u95ed\u8fde\u63a5&#xff0c;\u907f\u514d\u8d44\u6e90\u6d6a\u8d39\u3002<\/li>\n<h3>3. \u6a21\u5757\u8be6\u7ec6\u8bbe\u8ba1<\/h3>\n<p>\u7531\u4e8e\u4ee3\u7801\u592a\u957f&#xff0c;\u6e90\u7801\u6211\u7ed9\u51fa\u94fe\u63a5<\/p>\n<p><span class=\"link-card-box\"><span class=\"link-title\">\u6e90\u7801\u4e0b\u8f7d\u5730\u5740&#xff0c;\u5bc6\u7801:bhmy<\/span><span class=\"link-link\"><img decoding=\"async\" class=\"link-link-icon\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418101823-680226efebbd4.png\" alt=\"icon-default.png?t&#061;O83A\" \/>https:\/\/wwta.lanzoue.com\/iqugu2k8shij<\/span><\/span><\/p>\n<h4>3.1 CServer \u6a21\u5757<\/h4>\n<p>CServer \u7c7b\u662f\u6574\u4e2a HTTP \u670d\u52a1\u5668\u7684\u5165\u53e3&#xff0c;\u8d1f\u8d23\u542f\u52a8\u670d\u52a1\u5668&#xff0c;\u76d1\u542c\u5e76\u63a5\u53d7\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u3002\u5b83\u4f9d\u8d56\u4e8e Boost.Asio \u5e93\u63d0\u4f9b\u7684 tcp::acceptor \u6765\u76d1\u542c\u6307\u5b9a\u7684\u7aef\u53e3\u3002\u5f53\u5ba2\u6237\u7aef\u8fde\u63a5\u5230\u670d\u52a1\u5668\u65f6&#xff0c;CServer \u4f1a\u4e3a\u6bcf\u4e2a\u8fde\u63a5\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 HttpConnection \u5bf9\u8c61\u6765\u5904\u7406\u8be5\u8fde\u63a5\u3002<\/p>\n<h5>\u5173\u952e\u51fd\u6570&#xff1a;<\/h5>\n<ul>\n<li>Start()&#xff1a;\u542f\u52a8\u670d\u52a1\u5668\u5e76\u5f00\u59cb\u63a5\u53d7\u5ba2\u6237\u7aef\u8fde\u63a5\u3002<\/li>\n<li>Accept()&#xff1a;\u5f02\u6b65\u63a5\u53d7\u5ba2\u6237\u7aef\u8fde\u63a5&#xff0c;\u5f53\u6709\u65b0\u7684\u8fde\u63a5\u8bf7\u6c42\u65f6\u8c03\u7528 HttpConnection \u6765\u5904\u7406\u3002<\/li>\n<\/ul>\n<p>CServer \u7684\u4e3b\u8981\u4efb\u52a1\u662f\u521b\u5efa\u548c\u7ba1\u7406\u8fde\u63a5&#xff0c;\u6bcf\u5f53\u6709\u65b0\u7684\u8fde\u63a5\u8bf7\u6c42\u65f6&#xff0c;\u5b83\u4f1a\u4e3a\u8be5\u8fde\u63a5\u521b\u5efa\u4e00\u4e2a HttpConnection \u5bf9\u8c61&#xff0c;\u540e\u8005\u5c06\u8d1f\u8d23\u5904\u7406 HTTP \u8bf7\u6c42\u3002<\/p>\n<p>#ifndef CSERVER_H<br \/>\n#define CSERVER_H<br \/>\n#include &#034;const.h&#034;<\/p>\n<p>\/\/ CServer \u7c7b&#xff0c;\u8d1f\u8d23\u63a5\u53d7\u5ba2\u6237\u7aef\u8fde\u63a5\u5e76\u5904\u7406\u8fde\u63a5\u8bf7\u6c42<br \/>\nclass CServer :public std::enable_shared_from_this&lt;CServer&gt; {<br \/>\npublic:<br \/>\nCServer(boost::asio::io_context&amp; ioc, unsigned short&amp; port);\/\/ \u6784\u9020\u51fd\u6570&#xff1a;\u521d\u59cb\u5316\u670d\u52a1\u5668\u5e76\u7ed1\u5b9a\u5230\u6307\u5b9a\u7aef\u53e3<br \/>\nvoid Start(); \/\/ \u542f\u52a8\u670d\u52a1\u5668&#xff0c;\u5f00\u59cb\u63a5\u53d7\u8fde\u63a5<br \/>\nprivate:<br \/>\ntcp::acceptor _acceptor;\/\/ \u7528\u4e8e\u63a5\u53d7 TCP \u8fde\u63a5\u7684\u63a5\u53d7\u5668<br \/>\nnet::io_context&amp; _ioc;\/\/ \u63d0\u4f9b I\/O \u670d\u52a1\u7684\u4e0a\u4e0b\u6587\u5bf9\u8c61<br \/>\ntcp::socket _socket;\/\/ \u7528\u4e8e\u4e0e\u5ba2\u6237\u7aef\u901a\u4fe1\u7684\u5957\u63a5\u5b57<br \/>\n};<br \/>\n#endif<\/p>\n<h4>3.2 HttpConnection \u6a21\u5757<\/h4>\n<p>HttpConnection \u7c7b\u7ba1\u7406\u6bcf\u4e00\u4e2a\u5ba2\u6237\u7aef\u7684 HTTP \u8fde\u63a5\u3002\u5b83\u8d1f\u8d23\u5f02\u6b65\u8bfb\u53d6\u5ba2\u6237\u7aef\u8bf7\u6c42&#xff0c;\u89e3\u6790 HTTP \u8bf7\u6c42&#xff0c;\u67e5\u627e URL \u5bf9\u5e94\u7684\u56de\u8c03\u51fd\u6570&#xff0c;\u5e76\u751f\u6210 HTTP \u54cd\u5e94\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\u3002\u6b64\u5916&#xff0c;HttpConnection \u8fd8\u8d1f\u8d23\u8d85\u65f6\u7ba1\u7406&#xff0c;\u901a\u8fc7 Boost.Asio \u7684 steady_timer \u6765\u786e\u4fdd\u6bcf\u4e2a\u8fde\u63a5\u7684\u751f\u547d\u5468\u671f\u4e0d\u4f1a\u8fc7\u957f&#xff0c;\u4ece\u800c\u907f\u514d\u8d44\u6e90\u6cc4\u6f0f\u3002<\/p>\n<h5>\u5173\u952e\u51fd\u6570&#xff1a;<\/h5>\n<ul>\n<li>Start()&#xff1a;\u542f\u52a8\u8fde\u63a5&#xff0c;\u5f00\u59cb\u5904\u7406 HTTP \u8bf7\u6c42\u3002<\/li>\n<li>HandleReq()&#xff1a;\u5904\u7406 HTTP \u8bf7\u6c42&#xff0c;\u5305\u62ec\u89e3\u6790\u8bf7\u6c42\u5185\u5bb9\u5e76\u6839\u636e\u8bf7\u6c42\u65b9\u6cd5\u8c03\u7528\u76f8\u5e94\u7684\u56de\u8c03\u51fd\u6570\u3002<\/li>\n<li>CheckDeadline()&#xff1a;\u68c0\u67e5\u5f53\u524d\u8fde\u63a5\u662f\u5426\u8d85\u65f6&#xff0c;\u8d85\u65f6\u5219\u5173\u95ed\u8fde\u63a5\u3002<\/li>\n<li>WriteResponse()&#xff1a;\u5c06\u751f\u6210\u7684 HTTP \u54cd\u5e94\u6570\u636e\u5199\u5165\u5ba2\u6237\u7aef\u3002<\/li>\n<\/ul>\n<p>HttpConnection \u7684\u4efb\u52a1\u662f\u5728\u63a5\u6536\u5230\u8bf7\u6c42\u540e&#xff0c;\u89e3\u6790\u51fa\u8bf7\u6c42\u7684\u65b9\u6cd5&#xff08;GET\/POST&#xff09;\u3001URL \u548c\u53c2\u6570&#xff0c;\u5e76\u5c06\u5176\u4f20\u9012\u7ed9 LogicSystem \u6765\u8fdb\u884c\u540e\u7eed\u7684\u5904\u7406\u3002\u6700\u7ec8&#xff0c;\u5c06\u670d\u52a1\u5668\u7684\u54cd\u5e94\u53d1\u9001\u7ed9\u5ba2\u6237\u7aef\u3002<\/p>\n<p>#ifndef HTTPCONNECTION_H<br \/>\n#define HTTPCONNECTION_H<br \/>\n#include &#034;const.h&#034;<\/p>\n<p>\/\/ HttpConnection \u7c7b&#xff0c;\u8d1f\u8d23\u4e0e\u5ba2\u6237\u7aef\u7684 HTTP \u8fde\u63a5<br \/>\n\/\/ \u63d0\u4f9b\u5904\u7406 HTTP \u8bf7\u6c42\u3001\u5b9a\u65f6\u5668\u7ba1\u7406\u7b49\u529f\u80fd<br \/>\nclass HttpConnection :public std::enable_shared_from_this&lt;HttpConnection&gt; {<br \/>\nfriend class LogicSystem;\/\/ \u5141\u8bb8 LogicSystem \u8bbf\u95ee HttpConnection \u7684\u79c1\u6709\u6210\u5458<br \/>\npublic:<br \/>\nHttpConnection(tcp::socket socket);\/\/ \u6784\u9020\u51fd\u6570&#xff1a;\u63a5\u53d7 TCP \u5957\u63a5\u5b57&#xff0c;\u521d\u59cb\u5316\u8fde\u63a5<br \/>\nvoid Start(); \/\/ \u542f\u52a8\u8fde\u63a5\u5904\u7406<br \/>\nprivate:<br \/>\nvoid CheckDeadline();\/\/ \u68c0\u67e5\u662f\u5426\u8d85\u65f6&#xff0c;\u5b9a\u65f6\u5668\u529f\u80fd<br \/>\nvoid WriteResponse();\/\/ \u5199\u5165\u54cd\u5e94\u6570\u636e<br \/>\nvoid HandleReq(); \/\/ \u5904\u7406 HTTP \u8bf7\u6c42<br \/>\nvoid PreParseGetParam();\/\/\u5904\u7406\u53c2\u6570\u89e3\u6790<br \/>\ntcp::socket _socket;\/\/ \u5ba2\u6237\u7aef\u5957\u63a5\u5b57<br \/>\nbeast::flat_buffer _buffer{ 8192 };\/\/ \u63a5\u6536\u6570\u636e\u7684\u7f13\u51b2\u533a&#xff0c;\u6700\u5927\u7f13\u5b58 8192 \u5b57\u8282<br \/>\nhttp::request&lt;http::dynamic_body&gt; _request;\/\/ HTTP \u8bf7\u6c42\u5bf9\u8c61&#xff0c;\u5b58\u50a8\u63a5\u6536\u5230\u7684 HTTP \u8bf7\u6c42\u6570\u636e<br \/>\nhttp::response&lt;http::dynamic_body&gt; _response;\/\/ HTTP \u54cd\u5e94\u5bf9\u8c61&#xff0c;\u5b58\u50a8\u54cd\u5e94\u6570\u636e\u5e76\u53d1\u9001\u7ed9\u5ba2\u6237\u7aef<br \/>\n\/\/ \u5b9a\u65f6\u5668&#xff0c;\u68c0\u67e5\u8fde\u63a5\u662f\u5426\u8d85\u65f6&#xff0c;60 \u79d2\u540e\u81ea\u52a8\u5173\u95ed\u8fde\u63a5<br \/>\nnet::steady_timer deadline_{<br \/>\n_socket.get_executor(),std::chrono::seconds(60)<br \/>\n};<br \/>\nstd::string _get_url; \/\/ \u5b58\u50a8\u8bf7\u6c42\u7684 URL<br \/>\nstd::unordered_map&lt;std::string, std::string&gt; _get_params;\/\/ \u5b58\u50a8 GET \u8bf7\u6c42\u7684\u67e5\u8be2\u53c2\u6570&#xff0c;\u4ee5\u952e\u503c\u5bf9\u5f62\u5f0f\u5b58\u50a8<br \/>\n};<\/p>\n<p>#endif <\/p>\n<h4>3.3 LogicSystem \u6a21\u5757<\/h4>\n<p>LogicSystem \u7c7b\u662f\u6574\u4e2a\u7cfb\u7edf\u7684\u6838\u5fc3&#xff0c;\u8d1f\u8d23\u7ba1\u7406 HTTP \u8bf7\u6c42\u7684\u8def\u7531\u4e0e\u56de\u8c03\u51fd\u6570\u3002\u5b83\u91c7\u7528 \u5355\u4f8b\u6a21\u5f0f \u786e\u4fdd\u7cfb\u7edf\u4e2d\u53ea\u6709\u4e00\u4e2a\u903b\u8f91\u5904\u7406\u5b9e\u4f8b&#xff0c;\u5e76\u901a\u8fc7 std::map \u5b58\u50a8 GET \u548c POST \u8bf7\u6c42\u7684\u56de\u8c03\u51fd\u6570\u3002\u6bcf\u5f53 HTTP \u8bf7\u6c42\u5230\u6765\u65f6&#xff0c;HttpConnection \u4f1a\u5c06\u8bf7\u6c42\u7684 URL \u4f20\u9012\u7ed9 LogicSystem&#xff0c;\u7136\u540e\u6839\u636e\u8bf7\u6c42\u65b9\u6cd5&#xff08;GET\/POST&#xff09;\u67e5\u627e\u5e76\u6267\u884c\u5bf9\u5e94\u7684\u56de\u8c03\u51fd\u6570\u3002<\/p>\n<h5>\u5173\u952e\u51fd\u6570&#xff1a;<\/h5>\n<ul>\n<li>RegGet()&#xff1a;\u6ce8\u518c GET \u8bf7\u6c42\u7684\u56de\u8c03\u51fd\u6570\u3002<\/li>\n<li>RegPost()&#xff1a;\u6ce8\u518c POST \u8bf7\u6c42\u7684\u56de\u8c03\u51fd\u6570\u3002<\/li>\n<li>HandleGet()&#xff1a;\u5904\u7406 GET \u8bf7\u6c42&#xff0c;\u6267\u884c\u5bf9\u5e94\u7684\u56de\u8c03\u51fd\u6570\u3002<\/li>\n<li>HandlePost()&#xff1a;\u5904\u7406 POST \u8bf7\u6c42&#xff0c;\u6267\u884c\u5bf9\u5e94\u7684\u56de\u8c03\u51fd\u6570\u3002<\/li>\n<\/ul>\n<p>LogicSystem \u662f\u4e00\u4e2a\u5355\u4f8b\u7c7b&#xff0c;\u5b83\u4e3a\u6bcf\u4e2a\u8bf7\u6c42\u7c7b\u578b&#xff08;GET\/POST&#xff09;\u63d0\u4f9b\u4e86 URL \u5230\u56de\u8c03\u51fd\u6570\u7684\u6620\u5c04\u8868\u3002\u5f53\u8bf7\u6c42\u5230\u6765\u65f6&#xff0c;LogicSystem \u4f1a\u6839\u636e\u8bf7\u6c42\u7684 URL \u67e5\u627e\u76f8\u5e94\u7684\u56de\u8c03\u51fd\u6570\u5e76\u6267\u884c&#xff0c;\u4ece\u800c\u5b9e\u73b0\u4e0d\u540c URL \u5bf9\u5e94\u4e0d\u540c\u7684\u5904\u7406\u903b\u8f91\u3002<\/p>\n<p>#ifndef LOGICSYSTEM_H<br \/>\n#define LOGICSTSTEM_H<br \/>\n#include &#034;Singleton.h&#034;<br \/>\n#include &lt;functional&gt;<br \/>\n#include &lt;map&gt;<br \/>\n#include &#034;const.h&#034;<\/p>\n<p>class HttpConnection;<\/p>\n<p>typedef std::function&lt;void(std::shared_ptr&lt;HttpConnection&gt;)&gt; HttpHandler;\/\/ \u5b9a\u4e49\u4e00\u4e2a\u56de\u8c03\u51fd\u6570\u7c7b\u578b&#xff0c;\u5904\u7406 HTTP \u8bf7\u6c42<br \/>\n\/\/ HttpHandler \u901a\u8fc7 shared_ptr \u4f20\u9012 HttpConnection \u5bf9\u8c61<\/p>\n<p>\/\/ LogicSystem \u7c7b&#xff0c;\u7528\u4e8e\u7ba1\u7406 HTTP \u8bf7\u6c42\u7684\u903b\u8f91\u5904\u7406<br \/>\n\/\/ \u91c7\u7528\u5355\u4f8b\u6a21\u5f0f&#xff0c;\u786e\u4fdd\u7cfb\u7edf\u53ea\u6709\u4e00\u4e2a\u5b9e\u4f8b<br \/>\nclass LogicSystem : public Singleton&lt;LogicSystem&gt; {<br \/>\nfriend class Singleton&lt;LogicSystem&gt;; \/\/ \u5141\u8bb8 Singleton \u7c7b\u8bbf\u95ee LogicSystem \u7684\u6784\u9020\u51fd\u6570<br \/>\npublic:<br \/>\n~LogicSystem();\/\/ \u6790\u6784\u51fd\u6570&#xff0c;\u8d1f\u8d23\u91ca\u653e\u8d44\u6e90<br \/>\nbool HandleGet(std::string path, std::shared_ptr&lt;HttpConnection&gt; con); \/\/ \u5904\u7406GET\u8bf7\u6c42\u7684\u51fd\u6570<br \/>\nbool HandlePost(std::string path, std::shared_ptr&lt;HttpConnection&gt; con);\/\/\u5904\u7406POST\u8bf7\u6c42\u7684\u51fd\u6570<br \/>\nvoid RegGet(std::string url, HttpHandler handler);\/\/ \u6ce8\u518c GET \u8bf7\u6c42\u7684\u56de\u8c03\u51fd\u6570<br \/>\nvoid RegPost(std::string url, HttpHandler handler);\/\/ \u6ce8\u518cPOST\u8bf7\u6c42\u7684\u56de\u8c03\u51fd\u6570<br \/>\nprivate:<br \/>\nLogicSystem(); \/\/ \u6784\u9020\u51fd\u6570&#xff0c;\u79c1\u6709\u5316\u4ee5\u9632\u5916\u90e8\u76f4\u63a5\u521b\u5efa\u5b9e\u4f8b<br \/>\n\/\/key\u4e3a\u8def\u7531&#xff0c;value\u4e3a\u56de\u8c03\u51fd\u6570<br \/>\nstd::map&lt;std::string, HttpHandler&gt; _post_handlers; \/\/ \u5b58\u50a8 POST \u8bf7\u6c42\u7684\u5904\u7406\u51fd\u6570<br \/>\nstd::map&lt;std::string, HttpHandler&gt; _get_handlers; \/\/ \u5b58\u50a8 GET \u8bf7\u6c42\u7684\u5904\u7406\u51fd\u6570<br \/>\n};<br \/>\n#endif<\/p>\n<h4>3.4 Singleton \u6a21\u5757<\/h4>\n<p>Singleton \u6a21\u5757\u901a\u8fc7\u6a21\u677f\u5b9e\u73b0\u4e86\u5355\u4f8b\u6a21\u5f0f&#xff0c;\u786e\u4fdd\u7cfb\u7edf\u4e2d\u7684\u6838\u5fc3\u7ec4\u4ef6&#xff08;\u5982 LogicSystem&#xff09;\u53ea\u6709\u4e00\u4e2a\u5b9e\u4f8b\u3002\u8be5\u6a21\u677f\u7c7b\u4f7f\u7528\u61d2\u6c49\u5f0f\u521d\u59cb\u5316&#xff0c;\u786e\u4fdd\u5728\u9996\u6b21\u8bbf\u95ee\u65f6\u624d\u521b\u5efa\u5b9e\u4f8b&#xff0c;\u5e76\u4e14\u6bcf\u6b21\u8bbf\u95ee\u90fd\u8fd4\u56de\u540c\u4e00\u4e2a\u5b9e\u4f8b\u3002<\/p>\n<h5>\u5173\u952e\u51fd\u6570&#xff1a;<\/h5>\n<ul>\n<li>GetInstance()&#xff1a;\u83b7\u53d6\u5355\u4f8b\u5b9e\u4f8b&#xff0c;\u5982\u679c\u5b9e\u4f8b\u5c1a\u672a\u521b\u5efa&#xff0c;\u5219\u8fdb\u884c\u521d\u59cb\u5316\u3002<\/li>\n<li>PrintAddress()&#xff1a;\u6253\u5370\u5f53\u524d\u5355\u4f8b\u5b9e\u4f8b\u7684\u5730\u5740&#xff0c;\u4fbf\u4e8e\u8c03\u8bd5\u3002<\/li>\n<\/ul>\n<p>Singleton \u6a21\u5757\u4fdd\u8bc1\u4e86\u7cfb\u7edf\u4e2d\u53ea\u6709\u4e00\u4e2a\u5b9e\u4f8b&#xff0c;\u53ef\u4ee5\u6709\u6548\u907f\u514d\u91cd\u590d\u5b9e\u4f8b\u5316\u5e26\u6765\u7684\u8d44\u6e90\u6d6a\u8d39\u3002\u901a\u8fc7\u4f7f\u7528 std::shared_ptr \u7ba1\u7406\u5b9e\u4f8b\u7684\u751f\u547d\u5468\u671f&#xff0c;\u786e\u4fdd\u5b9e\u4f8b\u7684\u9500\u6bc1\u662f\u5728\u6240\u6709\u5f15\u7528\u90fd\u91ca\u653e\u540e\u8fdb\u884c\u7684\u3002<\/p>\n<p>#ifndef SINGLETON_H<br \/>\n#define SINGLETON_H<br \/>\n#include &lt;mutex&gt;<br \/>\n#include &lt;iostream&gt;<br \/>\n#include &lt;memory&gt;<\/p>\n<p>\/\/ Singleton \u6a21\u677f\u7c7b&#xff0c;\u786e\u4fdd\u4e00\u4e2a\u7c7b\u53ea\u6709\u4e00\u4e2a\u5b9e\u4f8b<br \/>\n\/\/ \u4f7f\u7528 std::shared_ptr \u6765\u7ba1\u7406\u5b9e\u4f8b\u751f\u547d\u5468\u671f<br \/>\ntemplate &lt;typename T&gt;<br \/>\nclass Singleton {<br \/>\nprotected:<br \/>\nSingleton() &#061; default;  \/\/ \u9ed8\u8ba4\u6784\u9020\u51fd\u6570&#xff0c;\u9632\u6b62\u5916\u90e8\u5b9e\u4f8b\u5316<br \/>\nSingleton(const Singleton&lt;T&gt;&amp;) &#061; delete; \/\/ \u7981\u6b62\u62f7\u8d1d\u6784\u9020<br \/>\nSingleton&amp; operator&#061;(const Singleton&lt;T&gt;&amp; st) &#061; delete; \/\/ \u7981\u6b62\u62f7\u8d1d\u8d4b\u503c<\/p>\n<p>static std::shared_ptr&lt;T&gt; _instance;\/\/ \u5b58\u50a8\u5355\u4f8b\u5b9e\u4f8b\u7684\u9759\u6001\u53d8\u91cf<br \/>\npublic:<br \/>\n\/\/ \u83b7\u53d6\u5355\u4f8b\u5b9e\u4f8b&#xff0c;\u7ebf\u7a0b\u5b89\u5168\u7684\u61d2\u6c49\u5f0f\u521d\u59cb\u5316<br \/>\nstatic std::shared_ptr&lt;T&gt; GetInstance() {<br \/>\nstatic std::once_flag s_flag;\/\/ \u7528\u4e8e\u786e\u4fdd\u5355\u4f8b\u5b9e\u4f8b\u53ea\u88ab\u521b\u5efa\u4e00\u6b21<br \/>\nstd::call_once(s_flag, [&amp;]() {<br \/>\n\/\/ \u521b\u5efa\u5355\u4f8b\u5b9e\u4f8b\u5e76\u4fdd\u5b58\u5728 _instance \u4e2d<br \/>\n_instance &#061; std::shared_ptr&lt;T&gt;(new T);<br \/>\n});<br \/>\nreturn _instance;\/\/ \u8fd4\u56de\u5355\u4f8b\u5b9e\u4f8b<br \/>\n}<br \/>\n\/\/ \u6253\u5370\u5f53\u524d\u5355\u4f8b\u5b9e\u4f8b\u7684\u5730\u5740<br \/>\nvoid PrintAddress() {<br \/>\nstd::cout &lt;&lt; _instance.get() &lt;&lt; std::endl;<br \/>\n}<br \/>\n\/\/ \u6790\u6784\u51fd\u6570&#xff0c;\u6253\u5370\u9500\u6bc1\u4fe1\u606f<br \/>\n~Singleton() {<br \/>\nstd::cout &lt;&lt; &#034;this is singleton destruct&#034; &lt;&lt; std::endl;<br \/>\n}<br \/>\n};<\/p>\n<p>\/\/ \u4e3a\u5355\u4f8b\u63d0\u4f9b\u9759\u6001\u53d8\u91cf\u7684\u521d\u59cb\u5316<br \/>\ntemplate&lt;typename T&gt;<br \/>\nstd::shared_ptr&lt;T&gt;Singleton&lt;T&gt;::_instance &#061; nullptr;<br \/>\n#endif<\/p>\n<h3>4.\u6d4b\u8bd5<\/h3>\n<p>\u8f93\u5165http:\/\/localhost:8080\/get_test<\/p>\n<p>\u663e\u793areceive get_test req<\/p>\n<\/p>\n<p>\u8f93\u5165http:\/\/localhost:8080\/get_test?key1&#061;value1&amp;key2&#061;value2<\/p>\n<p>\u663e\u793a<\/p>\n<p> receive get_test req<br \/>\nparam1key iskey1, value isvalue1<br \/>\nparam2key iskey2, value isvalue2\u00a0 <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.4k\u6b21\uff0c\u70b9\u8d5e13\u6b21\uff0c\u6536\u85cf21\u6b21\u3002\u57fa\u4e8e Boost.Asio \u548c Boost.Beast \u7684\u5f02\u6b65 HTTP \u670d\u52a1\u5668\uff08\u5b66\u4e60\u8bb0\u5f55\uff09_asio beast<\/p>\n","protected":false},"author":2,"featured_media":10903,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[151,58,493,43],"topic":[],"class_list":["post-10904","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-http","tag-linux","tag-vs2022","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u57fa\u4e8e Boost.Asio \u548c Boost.Beast \u7684\u5f02\u6b65 HTTP \u670d\u52a1\u5668\uff08\u5b66\u4e60\u8bb0\u5f55\uff09 - \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\/10904.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u57fa\u4e8e Boost.Asio \u548c Boost.Beast \u7684\u5f02\u6b65 HTTP \u670d\u52a1\u5668\uff08\u5b66\u4e60\u8bb0\u5f55\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.4k\u6b21\uff0c\u70b9\u8d5e13\u6b21\uff0c\u6536\u85cf21\u6b21\u3002\u57fa\u4e8e Boost.Asio \u548c Boost.Beast \u7684\u5f02\u6b65 HTTP \u670d\u52a1\u5668\uff08\u5b66\u4e60\u8bb0\u5f55\uff09_asio beast\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/10904.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T10:18:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418101823-680226efebbd4.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=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/10904.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/10904.html\",\"name\":\"\u57fa\u4e8e Boost.Asio \u548c Boost.Beast \u7684\u5f02\u6b65 HTTP \u670d\u52a1\u5668\uff08\u5b66\u4e60\u8bb0\u5f55\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T10:18:24+00:00\",\"dateModified\":\"2025-04-18T10:18:24+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/10904.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/10904.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/10904.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u57fa\u4e8e Boost.Asio \u548c Boost.Beast \u7684\u5f02\u6b65 HTTP \u670d\u52a1\u5668\uff08\u5b66\u4e60\u8bb0\u5f55\uff09\"}]},{\"@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":"\u57fa\u4e8e Boost.Asio \u548c Boost.Beast \u7684\u5f02\u6b65 HTTP \u670d\u52a1\u5668\uff08\u5b66\u4e60\u8bb0\u5f55\uff09 - \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\/10904.html","og_locale":"zh_CN","og_type":"article","og_title":"\u57fa\u4e8e Boost.Asio \u548c Boost.Beast \u7684\u5f02\u6b65 HTTP \u670d\u52a1\u5668\uff08\u5b66\u4e60\u8bb0\u5f55\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.4k\u6b21\uff0c\u70b9\u8d5e13\u6b21\uff0c\u6536\u85cf21\u6b21\u3002\u57fa\u4e8e Boost.Asio \u548c Boost.Beast \u7684\u5f02\u6b65 HTTP \u670d\u52a1\u5668\uff08\u5b66\u4e60\u8bb0\u5f55\uff09_asio beast","og_url":"https:\/\/www.wsisp.com\/helps\/10904.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T10:18:24+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418101823-680226efebbd4.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/10904.html","url":"https:\/\/www.wsisp.com\/helps\/10904.html","name":"\u57fa\u4e8e Boost.Asio \u548c Boost.Beast \u7684\u5f02\u6b65 HTTP \u670d\u52a1\u5668\uff08\u5b66\u4e60\u8bb0\u5f55\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T10:18:24+00:00","dateModified":"2025-04-18T10:18:24+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/10904.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/10904.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/10904.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u57fa\u4e8e Boost.Asio \u548c Boost.Beast \u7684\u5f02\u6b65 HTTP \u670d\u52a1\u5668\uff08\u5b66\u4e60\u8bb0\u5f55\uff09"}]},{"@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\/10904","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=10904"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/10904\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/10903"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=10904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=10904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=10904"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=10904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}