curl的HTTP参数速查表

curl简介

curl是一个开源的命令行工具,它基于网络协议,对指定URL进行网络传输,得到数据后不任何具体处理(如:html的渲染等),直接显示在"标准输出"(stdout)上。

curl支持的网络协议有很多,包括:DICT、FILE、FTP、FTPS、GOPHER、GOPHERS、HTTP、HTTPS、IMAP、IMAPS、LDAP、LDAPS、MQTT、POP3、POP3S、RTMP、RTMPS、RTSP、SCP、SFTP、SMB、SMBS、SMTP、SMTPS、TELNET和TFTP。

curl的参数也有很多,以下主要介绍HTTP和HTTPS相关的参数,建议收藏保存。

参数速查表

参数 描述 示例
-A, --user-agent <name> 发送指定的User-Agent到服务端 curl -A "Agent 007" https://one.more
--alt-svc <file name> 使用此缓存文件启用alt-svc curl --alt-svc svc.txt https://one.more
--anyauth 选择任意认证方法 curl --anyauth --user me:pwd https://one.more
--compressed 请求压缩 (使用 deflate 或 gzip) curl --compressed https://one.more
-b, --cookie <data filename> 发送cookie的字符串,或者读取发送cookie的文件位置 curl -b cookies.txt https://one.more
-c, --cookie-jar <filename> 操作结束后写入cookie到指定的文件 curl -c cookies.txt https://one.more
-d, --data <data> HTTP POST 的数据 curl -d "name=onemore" https://one.more
--data-ascii <data> HTTP POST 的ASCII数据 curl --data-ascii @file https://one.more
--data-binary <data> HTTP POST 的二进制数据 curl --data-binary @file https://one.more
--data-raw <data> HTTP POST 的数据(不对@字符做特殊解析) curl --data-raw "one@more" https://one.more
--data-urlencode <data> HTTP POST 的url编码的数据 curl --data-urlencode name=onemore https://one.more
--digest 使用HTTP摘要访问认证 curl -u name:password --digest https://one.more
--disallow-username-in-url 禁止在url中输入用户名 curl --disallow-username-in-url https://one.more
-D, --dump-header <filename> 把接收到的header写入到指定的文件 curl --dump-header header.txt https://one.more
-e, --referer <URL> 指定Referrer的URL curl --referer "https://more.one" https://one.more
--etag-compare <file> 从文件中读取作为header中的ETag curl --etag-compare etag.txt https://one.more
--etag-save <file> 从请求中解析ETag并将其保存到指定的文件中 curl --etag-save etag.txt https://one.more
--expect100-timeout <seconds> 允许等待100-continue响应的最大时间(以秒为单位) curl --expect100-timeout 2.5 https://one.more
-f, --fail 在服务器出错时不显示HTTP错误信息 curl --fail https://one.more
-F, --form <name=content> 模拟用户按下提交表单 curl -F image=@onemore.jpg https://one.more
--form-string <name=string> 模拟用户按下提交表单(值为字符串) curl --form-string "data" https://one.more
-G, --get 将POST数据放在URL中并发起GET请求 curl --get -d "name=onemore" https://one.more
--haproxy-protocol 发送HAProxy PROXY v1的header curl --haproxy-protocol https://one.more
-i, --include 在输出中包含HTTP响应头 curl -i https://one.more
-I, --head 只显示响应头信息 curl -I https://one.more
-H, --header header/@file 发送自定义header curl -H "Content-Type: application/json;charset=UTF-8" https://one.more
--hsts <file name> 启用HSTS进行传输 curl --hsts cache.txt https://one.more
--http0.9 使用HTTP 0.9 curl --http0.9 https://one.more
-0, --http1.0 使用HTTP 1.0 curl --http1.0 https://one.more
--http1.1 使用HTTP 1.1 curl --http1.1 https://one.more
--http2 使用HTTP 2 curl --http2 https://one.more
--http2-prior-knowledge 使用HTTP 2(不使用HTTP/1.1 Upgrade) curl --http2-prior-knowledge https://one.more
--http3 使用HTTP 3 curl --http3 https://one.more
--ignore-content-length 忽略服务端资源的大小 curl --ignore-content-length https://one.more
-j, --junk-session-cookies 忽略从文件中读取的会话cookie curl --junk-session-cookies -b cookies.txt https://one.more
-L, --location 启用重定向 curl --L https://one.more
--location-trusted 启用重定向并发送验证信息到其它主机 curl --location-trusted -u user:pwd https://one.more
--max-redirs <num> 重定向的最大次数 curl --max-redirs 3 --location https://one.more
--negotiate 使用HTTP Negotiate (SPNEGO) 认证 curl --negotiate -u : https://one.more
--no-alpn 禁用ALPN TLS扩展 curl --no-alpn https://one.more
--no-npn 禁用NPN TLS扩展 curl --no-npn https://one.more
--ntlm 使用HTTP NTLM认证 curl --ntlm -u user:pwd https://one.more
--ntlm-wb 使用HTTP NTLM认证(使用ntlmauth程序做身份验证) curl --ntlm-wb -u user:pwd https://one.more
--post301 在301重定向后不切换为 GET 请求 curl --post301 --location https://one.more
--post302 在302重定向后不切换为 GET 请求 curl --post302 --location https://one.more
--post303 在303重定向后不切换为 GET 请求 curl --post303 --location https://one.more
-r, --range <range> 只接收范围内的字节 curl --range 22-44 https://one.more
--raw 禁用所有内部HTTP对内容或传输编码的解码 curl --raw https://one.more
--tr-encoding 请求压缩传输编码算法,并解压接收到的数据 curl --tr-encoding https://one.more
-v, --verbose 显示通信的整个过程,包括端口连接和头信息。 curl -v https://one.more
-z, --time-cond <time> 请求在给定时间之后或之前被修改的文件 curl -z "Tue 18 Jan 2021 13:14:15" https://one.more

curl 版本号:7.74.0

最后,谢谢你这么帅,还给我点赞关注

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 220,884评论 6 513
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 94,212评论 3 395
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 167,351评论 0 360
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 59,412评论 1 294
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 68,438评论 6 397
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 52,127评论 1 308
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,714评论 3 420
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,636评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 46,173评论 1 319
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 38,264评论 3 339
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,402评论 1 352
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 36,073评论 5 347
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,763评论 3 332
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 32,253评论 0 23
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,382评论 1 271
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,749评论 3 375
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,403评论 2 358

推荐阅读更多精彩内容