獲取curl響應頭 CURL速查

2021-10-16 04:06:59 字數 1282 閱讀 6172

curl, 用於在命令列或指令碼中進行資料傳輸的工具。其主要功能通過libcurl進行實現。

curl自身已整合大量常用功能,例如:網路**、身份認證、ftp上傳、http post、ssl、cookie等,檔案續傳 等。且支援目前主流的大部分協議:dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtmp, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp。

curl -v --data-urlencode "name=你不知道我是誰" --data-urlencode "home=zhihu.com/people/w-w-l" zhihu.com

curl -v --form "name=你不知道我是誰" --form "home=zhihu.com/people/w-w-l" zhihu.com

curl -v --form "name=你不知道我是誰" --form "file=@~/tmp/test.txt" zhihu.com

curl -v -h x-home-page:zhihu.com/people/w-w-l
自動識別3xx狀態碼自動發起後續請求。

以知乎為例,通過curl訪問//的時候,伺服器檢查無身份認證資訊,從而返回響應的狀態碼為302,要求客戶端跳轉到登入頁///signin。

curl -v -l zhihu.com
通過-l引數,以上命令實際發出兩次請求,一次為//,第二次為///signin

curl的請求頭與響應頭獲取

1.從curl中獲取響應頭 ocurl curl init 設定請求頭,有時候需要,有時候不用,看請求 是否有對應的要求 返回 response header,該選項非常重要,如果不為 true,只會獲得響應的正文 curl setopt ocurl,curlopt header,true 是否不需...

curl 檢視HTTP 響應頭資訊

curl i http 1.1 200 ok http協議 http 返回碼 server tengine date fri,01 nov 2013 12 37 53 gmt content type text html charset gbk connection keep alive vary ...

curl檢查埠 使用curl獲取http狀態碼

shell中使用curl獲取http請求的狀態碼 bin bash 0 超時 logerr 檢測結果 t t請求超時或埠未開啟 logsucess 檢測結果 t t狀態正常 1 200 ok return 1 else 2 程式錯誤,狀態碼非200 logerr 檢測結果 t t應用程式錯誤 ret...