本文来自于 华为云社区, 为转载文章. 原创作者 为:

curl 参数速查表_重定向

在后面, 本人有补充了一些

原文章链接:​​https://bbs.huaweicloud.com/blogs/327417​

参数速查表

参数

描述

示例

-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的文件位置

-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

另外补充(可能有些是重复的):

-A/--user-agent <string>              设置用户代理发送给服务器
-b/--cookie <name=string/file> cookie字符串或文件读取位置
-c/--cookie-jar <file> 操作结束后把cookie写入到这个文件中
-C/--continue-at <offset> 断点续转
-D/--dump-header <file> 把header信息写入到该文件中
-e/--referer 来源网址
-f/--fail 连接失败时不显示http错误
-o/--output 把输出写到该文件中
-O/--remote-name 把输出写到该文件中,保留远程文件的文件名
-r/--range <range> 检索来自HTTP/1.1或FTP服务器字节范围
-s/--silent 静音模式。不输出任何东西
-T/--upload-file <file> 上传文件
-u/--user <user[:password]> 设置服务器的用户和密码
-w/--write-out [format] 什么输出完成后
-x/--proxy <host[:port]> 在给定的端口上使用HTTP代理
-#/--progress-bar 进度条显示当前的传送状态