curl
<p><a href="http://www.linuxeden.com/a/58757">http://www.linuxeden.com/a/58757</a>
<img src="https://www.showdoc.cc/server/api/common/visitfile/sign/10e61572373f5849f8e4c29af589d57f?showdoc=.jpg" alt="" /></p>
<h3>21个curl命令</h3>
<p>为了简单起见,我们将对 <a href="https://httpbin.org">https://httpbin.org</a> 发起一系列 HTTP 请求,httpbin 接受 HTTP 请求,然后在响应中回显你所发起的 HTTP 请求。</p>
<p>请求 <a href="https://httpbin.org">https://httpbin.org</a>
请求 <a href="https://httpbin.org/anything,它将会解析你发起的请求,并且在响应中回显。curl">https://httpbin.org/anything,它将会解析你发起的请求,并且在响应中回显。curl</a> 默认发起的是 GET 请求
向 <a href="https://httpbin.org/anything">https://httpbin.org/anything</a> 发起 GET 请求
向 <a href="https://httpbin.org/anything">https://httpbin.org/anything</a> 发起 GET 请求,但是这次需要添加一些查询参数(设置 value=panda)
请求 Google 的 robots.txt 文件 (www.google.com/robots.txt)
向 <a href="https://httpbin.org/anything">https://httpbin.org/anything</a> 发起 GET 请求,并且设置请求头为 User-Agent: elephant
向 <a href="https://httpbin.org/anything">https://httpbin.org/anything</a> 发起 DELETE 请求
请求 <a href="https://httpbin.org/anything">https://httpbin.org/anything</a> 并获取响应头信息
向 <a href="https://httpbin.com/anything">https://httpbin.com/anything</a> 发起请求体为 JSON {"value": "panda"} 的 POST 请求
发起与上一次相同的 POST 请求,但是这次要把请求头中的 Content-Type 字段设置成 application/json(因为 POST 请求需要一个与请求体相匹配的 Content-Type 请求头字段)。查看响应体中的 json 字段,对比上一次得到的响应体
向 <a href="https://httpbin.org/anything">https://httpbin.org/anything</a> 发起 GET 请求,并且在请求头中设置 Accept-Encoding: gzip(将会发生什么?为什么会这样?)
将一些 JSON 放在文件中,然后向 <a href="https://httpbin.org/anything">https://httpbin.org/anything</a> 发起请求体为该文件的 POST 请求
设置请求头为 Accept: image/png 并且向 <a href="https://httpbin.org/image">https://httpbin.org/image</a> 发起请求,将输出保存为 PNG 文件,然后使用图片浏览器打开。尝试使用不同的 Accept: 字段去请求此 URL
向 <a href="https://httpbin.org/anything">https://httpbin.org/anything</a> 发起 PUT 请求
请求 <a href="https://httpbin.org/image/jpeg">https://httpbin.org/image/jpeg</a> 并保存为文件,然后使用你的图片编辑器打开这个文件
请求 <a href="https://www.twitter.com,你将会得到空的响应。让">https://www.twitter.com,你将会得到空的响应。让</a> curl 显示出响应头信息,并尝试找出响应内容为空的原因
向 <a href="https://httpbin.org/anything">https://httpbin.org/anything</a> 发起任意的请求,同时设置一些无意义的请求头(例如:panda: elephant)
请求 <a href="https://httpbin.org/status/404">https://httpbin.org/status/404</a> 和 <a href="https://httpbin.org/status/200,然后再次请求它们并且让">https://httpbin.org/status/200,然后再次请求它们并且让</a> curl 显示响应头信息
请求 <a href="https://httpbin.org/anything">https://httpbin.org/anything</a> 并且设置用户名和密码(使用 -u username:password)
设置 Accept-Language: es-ES 的请求头用以下载 Twitter 的西班牙语主页 (<a href="https://twitter.com">https://twitter.com</a>)
使用 curl 向 Stripe API 发起请求(请查看 <a href="https://stripe.com/docs/development">https://stripe.com/docs/development</a> 了解如何使用,他们会给你一个测试用的 API key)。尝试向 <a href="https://httpbin.org/anything">https://httpbin.org/anything</a> 发起相同的请求</p>