<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
curl
,用於傳送請求的命令列工具,一個 HTTP 請求使用者端(實際上它也可以做 FTP/SCP/TELNET 協定的事情,可類比於瀏覽器中的 fetch。
curl
是最為流行的 HTTP 請求命令列工具,在谷歌瀏覽器控制檯的網路面板中,可將當前請求轉化為 curl
。
在學習及偵錯 HTTP 的過程中,可結合 curl
與 Apifo Echo 一同使用。
Apifox Echo
是 Apifox 出品的一款 HTTP 簡單的介面請求和返回資料服務,可以模擬各種介面請求引數和返回資料的情況,供開發人員和測試人員學習測試 API 使用。
直接傳送 GET 請求:
$ curl ifconfig.me 118.73.227.215
--request/-X
,指定請求方法,如 POST
等。
$ curl -X POST -H "Accept: application/vnd.github+json" -H "Authorization: token <TOKEN>" https://api.github.com/repos/OWNER/REPO/issues -d '{"title":"Found a bug","body":"I'''m having a problem with this.","assignees":["octocat"],"milestone":1,"labels":["bug"]}' $ curl https://echo.apifox.com/post -X POST -H "a: 3" -H "b: 4" { "args": {}, "data": "", "files": {}, "form": {}, "headers": { "A": "3", "Accept": "*/*", "B": "4", "Connection": "close", "Host": "echo.apifox.com", "User-Agent": "curl/7.79.1" }, "json": null, "origin": "118.113.0.137", "url": "https://echo.apifox.com/post" }
--head/-I
傳送 HEAD 請求,只需要返回 Response Header。
$ curl --head https://shanyue.tech HTTP/2 200 server: Tengine content-type: text/html; charset=utf-8 content-length: 33229 vary: Accept-Encoding date: Tue, 21 Jun 2022 05:54:24 GMT vary: Accept-Encoding x-oss-request-id: 62B15D1050ED1C32320FE906 x-oss-cdn-auth: success accept-ranges: bytes etag: "F540C0D57CDB57215AF11970EF4AAEF6" last-modified: Wed, 23 Mar 2022 14:57:44 GMT x-oss-object-type: Normal x-oss-hash-crc64ecma: 8545542358272103335 x-oss-storage-class: Standard x-oss-meta-mtime: 1648047444.796073379 cache-control: no-cache content-md5: 9UDA1XzbVyFa8Rlw70qu9g== x-oss-server-time: 27 ali-swift-global-savetime: 1655790864 via: cache12.l2cn3051[290,290,200-0,M], cache4.l2cn3051[291,0], kunlun6.cn3145[383,382,200-0,M], kunlun3.cn3145[386,0] x-cache: MISS TCP_MISS dirn:-2:-2 x-swift-savetime: Tue, 21 Jun 2022 05:54:24 GMT x-swift-cachetime: 0 timing-allow-origin: * eagleid: 791d26a916557908641262834e
--include/-i
,列印 Response Header 與 Response Body。
HTTP/1.1 200 OK access-control-allow-origin: * content-type: text/plain; charset=utf-8 content-length: 15 date: Wed, 17 Aug 2022 01:56:20 GMT x-envoy-upstream-service-time: 1 strict-transport-security: max-age=2592000; includeSubDomains server: istio-envoy Via: 1.1 google 222.222.222.113%
--verbose/-v
,檢視傳送報文及 TLS handshake 的詳細。
$ curl -vvv --head https://shanyue.tech * Rebuilt URL to: https://shanyue.tech/ * Trying 218.91.183.88... * TCP_NODELAY set * Connected to shanyue.tech (218.91.183.88) port 443 (#0) * ALPN, offering h3 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none * TLSv1.3 (OUT), TLS handshake, Client hello (1): * TLSv1.3 (IN), TLS handshake, Server hello (2): * TLSv1.3 (IN), TLS handshake, [no content] (0): * TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8): * TLSv1.3 (IN), TLS handshake, [no content] (0): * TLSv1.3 (IN), TLS handshake, Certificate (11): * TLSv1.3 (IN), TLS handshake, [no content] (0): * TLSv1.3 (IN), TLS handshake, CERT verify (15): * TLSv1.3 (IN), TLS handshake, [no content] (0): * TLSv1.3 (IN), TLS handshake, Finished (20): * TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1): * TLSv1.3 (OUT), TLS handshake, [no content] (0): * TLSv1.3 (OUT), TLS handshake, Finished (20): * SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 * ALPN, server accepted to use h3 * Server certificate: * subject: CN=shanyue.tech * start date: Feb 5 00:00:00 2022 GMT * expire date: Feb 6 23:59:59 2023 GMT * subjectAltName: host "shanyue.tech" matched cert's "shanyue.tech" * issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=Encryption Everywhere DV TLS CA - G1 * SSL certificate verify ok. * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * TLSv1.3 (OUT), TLS app data, [no content] (0): * TLSv1.3 (OUT), TLS app data, [no content] (0): * TLSv1.3 (OUT), TLS app data, [no content] (0): * Using Stream ID: 1 (easy handle 0x55c5a8e24690) * TLSv1.3 (OUT), TLS app data, [no content] (0): > HEAD / HTTP/2 > Host: shanyue.tech > User-Agent: curl/7.61.1 > Accept: */* > * TLSv1.3 (IN), TLS handshake, [no content] (0): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS handshake, [no content] (0): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS app data, [no content] (0): * Connection state changed (MAX_CONCURRENT_STREAMS == 128)! * TLSv1.3 (OUT), TLS app data, [no content] (0): * TLSv1.3 (IN), TLS app data, [no content] (0): < HTTP/2 200 HTTP/2 200 < server: Tengine server: Tengine < content-type: text/html; charset=utf-8 content-type: text/html; charset=utf-8 < content-length: 33229 content-length: 33229 < vary: Accept-Encoding vary: Accept-Encoding < date: Tue, 21 Jun 2022 06:02:59 GMT date: Tue, 21 Jun 2022 06:02:59 GMT < vary: Accept-Encoding vary: Accept-Encoding < x-oss-request-id: 62B15F13F15BB231391FB3A8 x-oss-request-id: 62B15F13F15BB231391FB3A8 < x-oss-cdn-auth: success x-oss-cdn-auth: success < accept-ranges: bytes accept-ranges: bytes < etag: "F540C0D57CDB57215AF11970EF4AAEF6" etag: "F540C0D57CDB57215AF11970EF4AAEF6" < last-modified: Wed, 23 Mar 2022 14:57:44 GMT last-modified: Wed, 23 Mar 2022 14:57:44 GMT < x-oss-object-type: Normal x-oss-object-type: Normal < x-oss-hash-crc64ecma: 8545542358272103335 x-oss-hash-crc64ecma: 8545542358272103335 < x-oss-storage-class: Standard x-oss-storage-class: Standard < x-oss-meta-mtime: 1648047444.796073379 x-oss-meta-mtime: 1648047444.796073379 < cache-control: no-cache cache-control: no-cache < content-md5: 9UDA1XzbVyFa8Rlw70qu9g== content-md5: 9UDA1XzbVyFa8Rlw70qu9g== < x-oss-server-time: 3 x-oss-server-time: 3 < ali-swift-global-savetime: 1655791379 ali-swift-global-savetime: 1655791379 < via: cache24.l2et15-1[66,66,200-0,M], cache44.l2et15-1[67,0], cache27.cn4056[128,128,200-0,M], cache64.cn4056[130,0] via: cache24.l2et15-1[66,66,200-0,M], cache44.l2et15-1[67,0], cache27.cn4056[128,128,200-0,M], cache64.cn4056[130,0] < x-cache: MISS TCP_MISS dirn:-2:-2 x-cache: MISS TCP_MISS dirn:-2:-2 < x-swift-savetime: Tue, 21 Jun 2022 06:02:59 GMT x-swift-savetime: Tue, 21 Jun 2022 06:02:59 GMT < x-swift-cachetime: 0 x-swift-cachetime: 0 < timing-allow-origin: * timing-allow-origin: * < eagleid: 088432cc16557913793393217e eagleid: 088432cc16557913793393217e < * Connection #0 to host shanyue.tech left intact
--location/-L
,追蹤重定向。
# 重定向兩次後請求到資料 $ curl --location http://zhihu.com # 可使用 --head,檢視到三次響應 $ curl --head --location http://zhihu.com
httpie 是現代化更為流行的一個 HTTP 使用者端,支援色彩、JSON 等。
# 傳送 JSON 資料給伺服器端,httpie 比 curl 方便很多,不需要自己手寫 header,curl 預設為 application/x-www-form-urlencoded $ http POST https://echo.apifox.com/post "a: 3" name=shanyue $ curl -X POST https://echo.apifox.com/post -H "a: 3" -H "content-type: application/json" -d '{"name": "shanyue"}' # 傳送 Form 資料給伺服器端,curl/httpie 都比較方便 $ http POST https://echo.apifox.com/post "a: 3" name=shanyue $ curl -X POST https://echo.apifox.com/post -H "a: 3" -d name=shanyue # 上傳檔案 $ http POST https://echo.apifox.com/post < Readme.md $ curl -X POST https://echo.apifox.com/post -H "content-type: application/json" -d @Readme.md # multipart 上傳檔案 $ http --multipart https://echo.apifox.com/post a=3 b@'Readme.md'
在 Apifox Echo 中,還可以將請求直接轉化為命令列。
以上就是Apifox Echo學習curl httpie 命令使用詳解的詳細內容,更多關於Apifox Echo命令curl httpie 的資料請關注it145.com其它相關文章!
相關文章
<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
综合看Anker超能充系列的性价比很高,并且与不仅和iPhone12/苹果<em>Mac</em>Book很配,而且适合多设备充电需求的日常使用或差旅场景,不管是安卓还是Switch同样也能用得上它,希望这次分享能给准备购入充电器的小伙伴们有所
2021-06-01 09:31:42
除了L4WUDU与吴亦凡已经多次共事,成为了明面上的厂牌成员,吴亦凡还曾带领20XXCLUB全队参加2020年的一场音乐节,这也是20XXCLUB首次全员合照,王嗣尧Turbo、陈彦希Regi、<em>Mac</em> Ova Seas、林渝植等人全部出场。然而让
2021-06-01 09:31:34
目前应用IPFS的机构:1 谷歌<em>浏览器</em>支持IPFS分布式协议 2 万维网 (历史档案博物馆)数据库 3 火狐<em>浏览器</em>支持 IPFS分布式协议 4 EOS 等数字货币数据存储 5 美国国会图书馆,历史资料永久保存在 IPFS 6 加
2021-06-01 09:31:24
开拓者的车机是兼容苹果和<em>安卓</em>,虽然我不怎么用,但确实兼顾了我家人的很多需求:副驾的门板还配有解锁开关,有的时候老婆开车,下车的时候偶尔会忘记解锁,我在副驾驶可以自己开门:第二排设计很好,不仅配置了一个很大的
2021-06-01 09:30:48
不仅是<em>安卓</em>手机,苹果手机的降价力度也是前所未有了,iPhone12也“跳水价”了,发布价是6799元,如今已经跌至5308元,降价幅度超过1400元,最新定价确认了。iPhone12是苹果首款5G手机,同时也是全球首款5nm芯片的智能机,它
2021-06-01 09:30:45