{"id":127686,"date":"2020-06-16T21:23:51","date_gmt":"2020-06-16T13:23:51","guid":{"rendered":"http:\/\/4563.org\/?p=127686"},"modified":"2020-06-16T21:23:51","modified_gmt":"2020-06-16T13:23:51","slug":"net-http-%e8%bf%94%e5%9b%9e%e7%8a%b6%e6%80%81%e7%a0%81%e6%98%af%e9%9d%9e-200-%e8%8e%b7%e5%8f%96%e5%93%8d%e5%ba%94%e4%bd%93%e7%96%91%e9%97%ae","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=127686","title":{"rendered":"net\/http \u8fd4\u56de\u72b6\u6001\u7801\u662f\u975e 200 \u83b7\u53d6\u54cd\u5e94\u4f53\u7591\u95ee"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  net\/http \u8fd4\u56de\u72b6\u6001\u7801\u662f\u975e 200 \u83b7\u53d6\u54cd\u5e94\u4f53\u7591\u95ee               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ropon <\/span>  <span><i><\/i> 6<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<h2>net\/http \u5305\u8bf7\u6c42\u4e00\u4e2a URL \u5730\u5740\uff0c\u8fd4\u56de\u72b6\u6001\u7801\u662f\u975e 200\uff0c\u6bd4\u5982 400\uff0c\u5982\u4f55\u83b7\u53d6\u54cd\u5e94\u4f53\u7684\u5185\u5bb9\u5462\uff1f<\/h2>\n<p>\u6d4b\u8bd5\u7ed3\u679c\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528 postman \u3001Python requests \u5e93\u83b7\u53d6\u5185\u5bb9<\/li>\n<\/ul>\n<pre><code>{     \"errcode\": 4023,     \"errmsg\": \"\u8ba4\u8bc1\u5931\u8d25\" } <\/code><\/pre>\n<ul>\n<li>\u4f7f\u7528 go net\/http \u5305 \u83b7\u53d6\u5185\u5bb9<\/li>\n<\/ul>\n<pre><code>&lt;!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 3.2 Final\/\/EN\"&gt; &lt;title&gt;400 Bad Request&lt;\/title&gt; &lt;h1&gt;Bad Request&lt;\/h1&gt; &lt;p&gt;The browser (or proxy) sent a request that this server could not understand.&lt;\/p&gt; <\/code><\/pre>\n<p>net\/http \u5305\u662f\u5426\u72b6\u6001\u7801 200 \u624d\u8bfb\u54cd\u5e94\u4f53\u7684\u5185\u5bb9\u5462\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>5<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"2108051\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : CEBBCAT <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             net\/http \u53ea\u6709\u5728 err \u4e0d\u4e3a nil \u65f6\u624d\u4e0d\u53ef\u4ee5\u8bfb\u53d6 resp.Body\uff0c\u5e95\u4e0b\u90a3\u4e2a\u5c31\u662f server \u8fd4\u56de\u7684\u6d88\u606f\u4f53\u3002<\/p>\n<p>\u4f60\u53ef\u4ee5\u4f7f\u7528 netcat \u76d1\u542c\u672c\u5730\u4e00\u4e2a\u7aef\u53e3\uff0c\u5bf9\u6bd4 postman \u6216 rewuests \u7684\u8bf7\u6c42\u4e0e net\/http \u7684\u8bf7\u6c42\u6709\u4ec0\u4e48\u5dee\u5f02\u3002<\/p>\n<p>\u4e0a\u9762\u90a3\u4e2a\u662f JSON\uff0c\u5e95\u4e0b\u90a3\u4e2a\u770b\u7740\u50cf\u662f HTTP \u670d\u52a1\u5668\u9ed8\u8ba4\u7684\u9519\u8bef\u9875\u9762\u3002\u6240\u4ee5\u4f60\u786e\u8ba4 postman \u548c go \u4ee3\u7801\u6d4b\u8bd5\u7684\u662f\u540c\u4e00\u4e2a\u670d\u52a1\u5668\u5417\uff1f postman \u90a3\u4e2a\u4e5f\u662f 400 \u9519\u8bef\u5417\uff1f<\/p>\n<p>\u4f60\u9700\u8981\u8865\u4e00\u70b9 HTTP \u7279\u522b\u662f TCP \u57fa\u7840\uff0c\u8fd9\u6837\u4f60\u5c31\u660e\u767d\u65e0\u8bba\u4ec0\u4e48 postman \u8fd8\u662f requests \u90fd\u53ef\u4ee5\u901a\u8fc7 telnet \u6765\u66ff\u4ee3\u3002<\/p>\n<p>\u4ee5\u53ca\u4f60\u516b\u6210\u8fd8\u8981\u5b66\u5b66\u300a\u63d0\u95ee\u7684\u667a\u6167\u300b\uff0c\u82e5\u662f\u53ef\u4ee5\uff0c\u8fd8\u53ef\u4ee5\u641c\u641c coolshell \u7684\u300e XY \u95ee\u9898\u300f                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2108052\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Vegetable <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u5bf9\u7684\uff0c\u4f60\u4e24\u4e2a\u8bf7\u6c42\u8fd4\u56de\u5185\u5bb9\u4e0d\u4e00\u6837\u3002<br \/>\u540e\u8fb9\u7684 html \u5c31\u662f body\uff0c\u663e\u7136\u4e0d\u662f\u4f60\u8bf4\u7684 json\uff0c\u5e94\u8be5\u662f\u8bf7\u6c42\u7684\u90e8\u5206\u9519\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2108053\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : CEBBCAT <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u770b\u8d77\u6765\u50cf\u662f\u4e2a\u524d\u8f88\u2026\u2026\u5947\u602a\u2026\u2026                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2108054\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : ropon <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5e94\u8be5\u662f\u7a0b\u5e8f\u95ee\u9898\uff08 https:\/\/github.com\/Ropon\/newpanel \uff09\uff0c\u65b0\u5199\u4e00\u4e2a demo \u53c8\u662f\u5bf9\u7684\u3002<br \/>D:SeafileGosrctest&gt;gor<br \/>{&#8220;errcode&#8221;: 4025, &#8220;errmsg&#8221;: &#8220;this is test&#8221;}                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2108055\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : ropon <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u627e\u5230\u95ee\u9898\u4e86\uff0c\u662f\u8fd9\u884c\u5f15\u8d77\u7684<br \/># api = Api(site_bp, default_mediatype=&#8221;application\/json;charset=utf-8&#8243;)<br \/>api = Api(site_bp)                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>net\/http \u8fd4\u56de\u72b6\u6001\u7801\u662f\u975e &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/127686"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=127686"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/127686\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=127686"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=127686"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=127686"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}