curl的HTTP参数速查表

简介: curl是一个开源的命令行工具,它基于网络协议,对指定URL进行网络传输,得到数据后不任何具体处理(如:html的渲染等),直接显示在"标准输出"(stdout)上。curl的参数也有很多,以下主要介绍HTTP和HTTPS相关的参数,建议收藏保存。

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 发送指定的User-Agent到服务端 curl -A "Agent 007" https://one.more
--alt-svc 使用此缓存文件启用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 操作结束后写入cookie到指定的文件 curl -c cookies.txt https://one.more
-d, --data HTTP POST 的数据 curl -d "name=onemore" https://one.more
--data-ascii HTTP POST 的ASCII数据 curl --data-ascii @file https://one.more
--data-binary HTTP POST 的二进制数据 curl --data-binary @file https://one.more
--data-raw HTTP POST 的数据(不对@字符做特殊解析) curl --data-raw "one@more" https://one.more
--data-urlencode 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 把接收到的header写入到指定的文件 curl --dump-header header.txt https://one.more
-e, --referer 指定Referrer的URL curl --referer "https://more.one" https://one.more
--etag-compare 从文件中读取作为header中的ETag curl --etag-compare etag.txt https://one.more
--etag-save 从请求中解析ETag并将其保存到指定的文件中 curl --etag-save etag.txt https://one.more
--expect100-timeout 允许等待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 启用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 重定向的最大次数 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 只接收范围内的字节 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 请求在给定时间之后或之前被修改的文件 curl -z "Tue 18 Jan 2021 13:14:15" https://one.more
curl 版本号:7.74.0
相关文章
|
网络协议 Linux 网络安全
curl(http命令行工具):Linux下最强大的网络数据传输工具
curl(http命令行工具):Linux下最强大的网络数据传输工具
720 0
|
JSON 搜索推荐 网络协议
玩转curl指令—测试简单的HTTP接口
玩转curl指令—测试简单的HTTP接口
1369 0
|
9月前
|
安全 Linux 定位技术
Curl访问Kerberos SPNEGO保护的HTTP资源
最后,记住,虽然Kerberos的魔法强大且久经考验,但它仍需你谨慎掌握。SPNEGO的舞步看似复杂,但一旦跳起来,你会发现自己在安全和便捷的旋律中翩翩起舞。而Curl,这一灵活敏捷的小工具,它的确有能力成为你施展这些魔法的得力助手。
266 14
|
11月前
|
JSON API 数据安全/隐私保护
使用curl命令在服务器上执行HTTP请求
总的来说,curl是一个非常强大的工具,它可以让你在命令行中发送各种类型的HTTP请求。通过学习和实践,你可以掌握这个工具,使你的工作更加高效。
985 30
|
API
掌握 HTTP 请求的艺术:理解 cURL GET 语法
掌握 cURL GET 请求的语法和使用方法是 Web 开发和测试中的基本技能。通过灵活运用 cURL 提供的各种选项,可以高效地与 API 进行交互、调试网络请求,并自动化日常任务。希望本文能帮助读者更好地理解和使用 cURL,提高工作效率和代码质量。
1284 7
|
存储 网络安全
Curl error (60): SSL peer certificate or SSH remote key was not OK for https://update.cs2c.com.cn/NS/V10/V10SP2/os/adv/lic/base/x86_64/repodata/repomd.xml [SSL: no alternative certificate subject name matches target host name 'update.cs2c.com.cn']
【10月更文挑战第30天】在尝试从麒麟软件仓库(ks10-adv-os)下载元数据时,遇到 SSL 证书验证问题。错误提示为:`Curl error (60): SSL peer certificate or SSH remote key was not OK`。可能原因包括证书不被信任、证书与域名不匹配或网络问题。解决方法包括检查网络连接、导入 SSL 证书、禁用 SSL 证书验证(不推荐)、联系仓库管理员、检查系统时间和尝试其他镜像。
4409 1
|
存储 算法 数据安全/隐私保护
基于 HTTP Header 传输签名参数
基于 HTTP Header 传输签名参数
363 13
|
移动开发 JavaScript 前端开发
"解锁axios GET请求新姿势!揭秘如何将数组参数华丽变身,让你的HTTP请求在云端翩翩起舞,挑战技术极限!"
【8月更文挑战第20天】二维码在移动应用中无处不在。本文详述了在UniApp H5项目中实现二维码生成与扫描的方法。通过对比插件`uni-app-qrcode`和库`qrcode-generator`生成二维码,以及使用插件和HTML5 API进行扫描,帮助开发者挑选最佳方案。无论是即插即用的插件还是灵活的JavaScript实现,都能满足不同需求。
149 0
|
人工智能
AI绘画,Stable Diffusion如何使用中文简体包,黑色页面切换参数http://127.0.0.1:7860/?__theme=dark 两个__,中文包下载和安装
AI绘画,Stable Diffusion如何使用中文简体包,黑色页面切换参数http://127.0.0.1:7860/?__theme=dark 两个__,中文包下载和安装
|
JSON API 数据格式
curl 使用:命令行中的 HTTP 客户端
`curl` 是命令行神器,用于与服务器交互,支持HTTP、HTTPS、FTP等协议。本文教你如何用它做POST请求(-d/--data)、GET请求(-G/-d)、JSON请求(-H &#39;Content-Type: application/json&#39;)和文件上传(-F)。学会这些,轻松测试API、自动化任务。现在就动手试试吧!
690 0