{"id":453,"date":"2024-08-04T10:23:32","date_gmt":"2024-08-04T02:23:32","guid":{"rendered":"https:\/\/thereisno.top:4430\/?p=453"},"modified":"2024-08-04T10:23:33","modified_gmt":"2024-08-04T02:23:33","slug":"curl%e5%8f%91%e9%80%81%e8%af%b7%e6%b1%82","status":"publish","type":"post","link":"https:\/\/thereisno.top\/?p=453","title":{"rendered":"curl\u53d1\u9001\u8bf7\u6c42"},"content":{"rendered":"\n<p>\u6211\u4eec\u5728\u5ba2\u6237\u7aef\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u603b\u514d\u4e0d\u4e86\u548c\u540e\u7aef\u8fdb\u884capi\u5bf9\u63a5\uff0c\u6709\u65f6\u5019\u9700\u8981\u5bf9\u8fd4\u56de\u7684\u6570\u636e\u683c\u5f0f\u8fdb\u884c\u8c03\u8bd5\uff0c\u6709\u65f6\u5019\u6bcf\u6b21\u8fd0\u884c\u5ba2\u6237\u7aef\u6765\u53d1\u9001\u8bf7\u6c42\uff0c\u8fd9\u4e2a\u672a\u514d\u6548\u7387\u592a\u4f4e\uff0c\u8fd9\u91cc\u5c31\u6765\u4ecb\u7ecd\u4e00\u4e2a\u597d\u7528\u7684\u5de5\u5177\u2013curl\u3002<\/p>\n\n\n\n<p>curl<\/p>\n\n\n\n<p>curl\u662f\u4e00\u4e2a\u5411\u670d\u52a1\u5668\u4f20\u8f93\u6570\u636e\u7684\u5de5\u5177\uff0c\u5b83\u652f\u6301http\u3001https\u3001ftp\u3001ftps\u3001scp\u3001sftp\u3001tftp\u3001telnet\u7b49\u534f\u8bae\uff0c\u8fd9\u91cc\u53ea\u9488\u5bf9http\u8fdb\u884c\u8bb2\u89e3\u4e00\u4e9b\u5e38\u7528\u7684\u7528\u6cd5\uff0c\u5177\u4f53\u5b89\u88c5\u8bf7\u81ea\u884c\u641c\u7d22\u3002<\/p>\n\n\n\n<p>\u6253\u5f00\u767e\u5ea6<\/p>\n\n\n\n<p>curl <a href=\"http:\/\/www.baidu.com\">http:\/\/www.baidu.com<\/a><\/p>\n\n\n\n<p>\u63a5\u7740\u4f60\u5c31\u4f1a\u770b\u5230\u767e\u5ea6\u7684\u9875\u9762\u6e90\u4ee3\u7801\u8f93\u51fa\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u8981\u628a\u8fd9\u4e2a\u7f51\u9875\u4fdd\u5b58\u4e0b\u6765\uff0c\u53ef\u4ee5\u8fd9\u6837\uff1a<\/p>\n\n\n\n<p>curl <a href=\"http:\/\/www.baidu.com\">http:\/\/www.baidu.com<\/a> &gt; \/tmp\/baidu.html<\/p>\n\n\n\n<p>\u4f60\u4f1a\u770b\u5230\u4e00\u6761\u8fdb\u5ea6\u6761\uff0c\u7136\u540e\u6e90\u7801\u5c31\u88ab\u91cd\u5b9a\u5411\u5230\u4e86\/tmp\/baidu.html\u3002<\/p>\n\n\n\n<p>\u6216\u8005\uff1a<\/p>\n\n\n\n<p>curl -o \/tmp\/baidu.html <a href=\"http:\/\/www.baidu.com\">http:\/\/www.baidu.com<\/a><\/p>\n\n\n\n<p>GET\u8bf7\u6c42<\/p>\n\n\n\n<p>\u9ed8\u8ba4\u76f4\u63a5\u8bf7\u6c42\u4e00\u4e2aurl\u5c31\u662f\u53d1\u51fa\u4e00\u4e2aget\u8bf7\u6c42\uff0c\u53c2\u6570\u7684\u8bdd\u76f4\u63a5\u62fc\u63a5\u5728url\u91cc\u5c31\u597d\u4e86\uff0c\u5982<\/p>\n\n\n\n<p>curl <a href=\"http:\/\/www.baidu.com\/s?wd=curl\">http:\/\/www.baidu.com\/s?wd=curl<\/a><\/p>\n\n\n\n<p>\u4e0a\u8ff0\u8bf7\u6c42\u4f1a\u4e0a\u767e\u5ea6\u53d1\u8d77\u4e00\u6761\u67e5\u8be2\u8bf7\u6c42\uff0c\u53c2\u6570\u662fwd=url<\/p>\n\n\n\n<p>POST\u8bf7\u6c42<\/p>\n\n\n\n<p>curl -d &#8220;name=test&amp;page=1&#8221; <a href=\"http:\/\/www.baidu.com\">http:\/\/www.baidu.com<\/a><\/p>\n\n\n\n<p><strong>-d <\/strong>\u53c2\u6570\u6307\u5b9a\u8868\u5355\u4ee5POST\u7684\u5f62\u5f0f\u6267\u884c\u3002<\/p>\n\n\n\n<p>\u53ea\u5c55\u793aHeader<\/p>\n\n\n\n<p>curl -I&nbsp; <a href=\"http:\/\/www.baidu.com\">http:\/\/www.baidu.com<\/a><\/p>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\u53ea\u8fd4\u56de\u4e00\u4e9bheader\u4fe1\u606f<\/p>\n\n\n\n<p>HTTP\/1.1 200 OK<br>Date: Fri, 07 Nov 2014 09:48:58 GMT<br>Content-Type: text\/html; charset=utf-8<br>Connection: Keep-Alive<br>Vary: Accept-Encoding<br>Set-Cookie: BAIDUID=E9DB2F0AC95CB6BFDAD9D5CFDCED0A12:FG=1; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=\/; domain=.baidu.com<br>Set-Cookie: BAIDUPSID=E9DB2F0AC95CB6BFDAD9D5CFDCED0A12; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=\/; domain=.baidu.com<br>Set-Cookie: BDSVRTM=0; path=\/<br>Set-Cookie: BD_HOME=0; path=\/<br>Set-Cookie: H_PS_PSSID=9725_9165_1465_7800_9452_9498_6504_9509_6018_9700_9757_9531_9478_7798_9453_9793_9024; path=\/; domain=.baidu.com<br>P3P: CP=&#8221; OTI DSP COR IVA OUR IND COM &#8220;<br>Cache-Control: private<br>Cxy_all: baidu+3057b288b211c770a1463cc8519b62a8<br>Expires: Fri, 07 Nov 2014 09:48:17 GMT<br>X-Powered-By: HPHP<br>Server: BWS\/1.1<br>BDPAGETYPE: 1<br>BDQID: 0xfa28eff900012706<br>BDUSERID: 0<\/p>\n\n\n\n<p>\u663e\u793a\u901a\u4fe1\u8fc7\u7a0b<\/p>\n\n\n\n<p>-v\u53c2\u6570\u53ef\u4ee5\u663e\u793a\u4e00\u6b21http\u901a\u4fe1\u7684\u6574\u4e2a\u8fc7\u7a0b\uff0c\u5305\u62ec\u7aef\u53e3\u8fde\u63a5\u548chttp request\u5934\u4fe1\u606f<\/p>\n\n\n\n<p>curl -v <a href=\"http:\/\/www.baidu.com\">www.baidu.com<\/a><\/p>\n\n\n\n<p>* Adding handle: conn: 0x7ffe4b003a00<br>* Adding handle: send: 0<br>* Adding handle: recv: 0<br>* Curl_addHandleToPipeline: length: 1<br>* &#8211; Conn 0 (0x7ffe4b003a00) send_pipe: 1, recv_pipe: 0<br>* About to connect() to <a href=\"http:\/\/www.baidu.com\">www.baidu.com<\/a> port 80 (#0)<br>*&nbsp;&nbsp; Trying 61.135.169.125&#8230;<br>* Connected to <a href=\"http:\/\/www.baidu.com\">www.baidu.com<\/a> (61.135.169.125) port 80 (#0)<br>&gt; GET \/ HTTP\/1.1<br>&gt; User-Agent: curl\/7.30.0<br>&gt; Host: <a href=\"http:\/\/www.baidu.com\">www.baidu.com<\/a><br>&gt; Accept: *\/*<br>&gt;<br>&lt; HTTP\/1.1 200 OK<br>&lt; Date: Fri, 07 Nov 2014 09:49:49 GMT<br>&lt; Content-Type: text\/html; charset=utf-8<br>&lt; Transfer-Encoding: chunked<br>&lt; Connection: Keep-Alive<br>&lt; Vary: Accept-Encoding<br>&lt; Set-Cookie: BAIDUID=062E02D23FBB651CF8455B699DF02B64:FG=1; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=\/; domain=.baidu.com<br>&lt; Set-Cookie: BAIDUPSID=062E02D23FBB651CF8455B699DF02B64; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=\/; domain=.baidu.com<br>&lt; Set-Cookie: BDSVRTM=0; path=\/<br>&lt; Set-Cookie: BD_HOME=0; path=\/<br>&lt; Set-Cookie: H_PS_PSSID=7744_1429_7801_9583_9499_6506_6018_9769_9699_9757_9532_9477_7799_9453_9716_9023; path=\/; domain=.baidu.com<br>&lt; P3P: CP=&#8221; OTI DSP COR IVA OUR IND COM &#8220;<br>&lt; Cache-Control: private<br>&lt; Cxy_all: baidu+7dcb6b3c03d32c334d42f311919a14d6<br>&lt; Expires: Fri, 07 Nov 2014 09:49:20 GMT<br>&lt; X-Powered-By: HPHP<br>* Server BWS\/1.1 is not blacklisted<br>&lt; Server: BWS\/1.1<br>&lt; BDPAGETYPE: 1<br>&lt; BDQID: 0xadb706860000088f<br>&lt; BDUSERID: 0<\/p>\n\n\n\n<p>\u5982\u679c\u4f60\u89c9\u5f97\u4e0a\u9762\u7684\u4fe1\u606f\u8fd8\u4e0d\u591f\uff0c\u90a3\u4e48\u4e0b\u9762\u7684\u547d\u4ee4\u53ef\u4ee5\u67e5\u770b\u66f4\u8be6\u7ec6\u7684\u901a\u4fe1\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<p>curl &#8211;trace output.txt <a href=\"http:\/\/www.baidu.com\">www.baidu.com<\/a><\/p>\n\n\n\n<p>\u6216\u8005<\/p>\n\n\n\n<p>curl &#8211;trace-ascii output.txt <a href=\"http:\/\/www.baidu.com\">www.baidu.com<\/a><\/p>\n\n\n\n<p>\u8fd0\u884c\u540e\uff0c\u8bf7\u6253\u5f00output.txt\u6587\u4ef6\u67e5\u770b\u3002<\/p>\n\n\n\n<p>HTTP\u65b9\u6cd5<\/p>\n\n\n\n<p>curl\u9ed8\u8ba4\u7684HTTP\u65b9\u6cd5\u662fGET\uff0c\u4f7f\u7528-X\u53c2\u6570\u53ef\u4ee5\u652f\u6301\u5176\u4ed6\u52a8\u8bcd\u3002<\/p>\n\n\n\n<p>curl -X POST <a href=\"http:\/\/www.example.com\">www.example.com<\/a><\/p>\n\n\n\n<p>curl -X DELETE <a href=\"http:\/\/www.example.com\">www.example.com<\/a><\/p>\n\n\n\n<p>Referer\u5b57\u6bb5<\/p>\n\n\n\n<p>\u6709\u65f6\u4f60\u9700\u8981\u5728http request\u5934\u4fe1\u606f\u4e2d\uff0c\u63d0\u4f9b\u4e00\u4e2areferer\u5b57\u6bb5\uff0c\u8868\u793a\u4f60\u662f\u4ece\u54ea\u91cc\u8df3\u8f6c\u8fc7\u6765\u7684\u3002<\/p>\n\n\n\n<p>curl &#8211;referer <a href=\"http:\/\/www.example.com\">http:\/\/www.example.com<\/a> <a href=\"http:\/\/www.example.com\">http:\/\/www.example.com<\/a><\/p>\n\n\n\n<p>User Agent\u5b57\u6bb5<\/p>\n\n\n\n<p>\u8fd9\u4e2a\u5b57\u6bb5\u662f\u7528\u6765\u8868\u793a\u5ba2\u6237\u7aef\u7684\u8bbe\u5907\u4fe1\u606f\u3002\u670d\u52a1\u5668\u6709\u65f6\u4f1a\u6839\u636e\u8fd9\u4e2a\u5b57\u6bb5\uff0c\u9488\u5bf9\u4e0d\u540c\u8bbe\u5907\uff0c\u8fd4\u56de\u4e0d\u540c\u683c\u5f0f\u7684\u7f51\u9875\uff0c\u6bd4\u5982\u624b\u673a\u7248\u548c\u684c\u9762\u7248\u3002<\/p>\n\n\n\n<p>iPhone4\u7684User Agent\u662f<\/p>\n\n\n\n<p>Mozilla\/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit\/532.9 (KHTML, like Gecko) Version\/4.0.5 Mobile\/8A293 Safari\/6531.22.7<\/p>\n\n\n\n<p>curl\u53ef\u4ee5\u8fd9\u6837\u6a21\u62df\uff1a<\/p>\n\n\n\n<p>curl &#8211;user-agent &#8220;[User Agent]&#8221; [URL]<\/p>\n\n\n\n<p>\u589e\u52a0\u5934\u4fe1\u606f<\/p>\n\n\n\n<p>\u6709\u65f6\u9700\u8981\u5728http request\u4e4b\u4e2d\uff0c\u81ea\u884c\u589e\u52a0\u4e00\u4e2a\u5934\u4fe1\u606f\u3002\u2013header\u53c2\u6570\u5c31\u53ef\u4ee5\u8d77\u5230\u8fd9\u4e2a\u4f5c\u7528\u3002<\/p>\n\n\n\n<p>curl &#8211;header &#8220;Content-Type:application\/json&#8221; <a href=\"http:\/\/example.com\">http:\/\/example.com<\/a><\/p>\n\n\n\n<p>\u6765\u81ea &lt;<a href=\"http:\/\/stormzhang.com\/devtools\/2014\/11\/07\/use-curl-debug\/\">http:\/\/stormzhang.com\/devtools\/2014\/11\/07\/use-curl-debug\/<\/a>&gt;<\/p>\n\n\n\n<p>-H, \u2014header LINE Custom header to pass to server (H)<\/p>\n\n\n\n<p>-d, \u2014data DATA HTTP POST data (H)<\/p>\n\n\n\n<p><strong>\u793a\u4f8b\u547d\u4ee4<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>1<\/td><td>curl -H &#8220;Content-Type: application\/json&#8221; -d &#8216;{&#8220;object_kind&#8221;:&#8221;merge_request&#8221;,&#8221;object_attributes&#8221;:{&#8220;id&#8221;:22,&#8221;target_branch&#8221;:&#8221;master&#8221;,&#8221;source_branch&#8221;:&#8221;master&#8221;,&#8221;source_project_id&#8221;:57,&#8221;author_id&#8221;:9,&#8221;assignee_id&#8221;:null,&#8221;title&#8221;:&#8221;Master Title&#8221;,&#8221;created_at&#8221;:&#8221;2014-07-02T02:31:20.000Z&#8221;,&#8221;updated_at&#8221;:&#8221;2014-07-02T02:36:33.008Z&#8221;,&#8221;milestone_id&#8221;:null,&#8221;state&#8221;:&#8221;closed&#8221;,&#8221;merge_status&#8221;:&#8221;unchecked&#8221;,&#8221;target_project_id&#8221;:55,&#8221;iid&#8221;:7,&#8221;description&#8221;:&#8221;description_content&#8221;}}&#8217; <a href=\"http:\/\/10.0.6.122:9002\/merge_request\">http:\/\/10.0.6.122:9002\/merge_request<\/a><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u6765\u81ea &lt;<a href=\"https:\/\/cloud.tencent.com\/developer\/article\/1328118\">https:\/\/cloud.tencent.com\/developer\/article\/1328118<\/a>&gt;<\/p>\n\n\n\n<p>curl -v -H &#8220;Content-Type:application\/json&#8221; \\<\/p>\n\n\n\n<p>-H&nbsp; &#8220;Authorization:Basic Y2xpZW50Q3JlZGVudGlhbHNJZDpzZWNyZXQ=&#8221; \\<\/p>\n\n\n\n<p>-X POST&nbsp; <a href=\"http:\/\/172.16.5.172:3396\/crm\/oauth\/token?grant_type=client_credentials\">http:\/\/172.16.5.172:3396\/crm\/oauth\/token?grant_type=client_credentials<\/a><\/p>\n\n\n\n<p>\u8bf7\u6c42soup<\/p>\n\n\n\n<p>curl -X POST -d @testrequest.xml \\<\/p>\n\n\n\n<p>&#8211;header &#8220;Content-Type:application\/json&#8221; \\<\/p>\n\n\n\n<p>http:\/\/localhost:8080\/services\/xxxxService<\/p>\n\n\n\n<p>testrequest.xml<\/p>\n\n\n\n<p>&lt;soapenv:Envelope xmlns:soapenv=&#8221;http:\/\/schemas.xmlsoap.org\/soap\/envelope\/&#8221; xmlns:ent=&#8221;http:\/\/entity.xxx.com&#8221;><\/p>\n\n\n\n<p>&nbsp;&nbsp; &lt;soapenv:Header\/&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp; &lt;soapenv:Body&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ent:getTableData&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;!&#8211;Optional:&#8211;&gt;<\/p>\n\n\n\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;ent:oaUsername>zhangsan&lt;\/ent:oaUsername><\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/ent:getTableData&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp; &lt;\/soapenv:Body&gt;<\/p>\n\n\n\n<p>&lt;\/soapenv:Envelope&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4eec\u5728\u5ba2\u6237\u7aef\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u603b\u514d\u4e0d\u4e86\u548c\u540e\u7aef\u8fdb\u884capi\u5bf9\u63a5\uff0c\u6709\u65f6\u5019\u9700\u8981\u5bf9\u8fd4\u56de\u7684\u6570\u636e\u683c\u5f0f\u8fdb\u884c\u8c03\u8bd5\uff0c\u6709\u65f6\u5019\u6bcf\u6b21\u8fd0\u884c\u5ba2\u6237\u7aef\u6765 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/thereisno.top\/?p=453\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201ccurl\u53d1\u9001\u8bf7\u6c42\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,41],"tags":[10,72],"class_list":["post-453","post","type-post","status-publish","format-standard","hentry","category-linux","category-macos","tag-linux","tag-macos"],"_links":{"self":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts\/453","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=453"}],"version-history":[{"count":1,"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts\/453\/revisions"}],"predecessor-version":[{"id":454,"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts\/453\/revisions\/454"}],"wp:attachment":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=453"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=453"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}