命令CURL 的 look back

124 阅读2分钟

好久没用到curl了,突然有一天公司来了个需求需要下载几个单个将近200G的zip包,奶球的竟然忘记了命令行的参数。。。于是写这一篇文档作为一个总结资料吧!

官网对CURL的解释**:** curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies (SOCKS4, SOCKS5, HTTP and HTTPS), HTTP/2, HTTP/3, cookies, user+password authentication (Basic, Plain, Digest, CRAM-MD5, SCRAM-SHA, NTLM, Negotiate, Kerberos, Bearer tokens and AWS Sigv4), file transfer resume, proxy tunneling, HSTS, Alt-Svc, unix domain sockets, HTTP compression (gzip, brotli and zstd), etags, parallel transfers, DNS-over-HTTPS and more.

翻译: curl支持SSL证书、HTTP POST、HTTP PUT、FTP上载、基于HTTP表单的上载、代理(SOCKS4、SOCKS5、HTTP和HTTPS)、HTTP/2、HTTP/3、cookie、用户+密码身份验证(Basic、Plain、Digest、CRAM-MD5、SCRAM-SHA、NTLM、Negotiate、Kerberos、Bearer令牌和AWS Sigv4)、文件传输恢复、代理隧道、HSTS、Alt-Svc、unix域套接字,HTTP压缩(gzip、brotli和zstd)、etags、并行传输、HTTPS上的DNS等等。

常用命令如下:

  • -d, --data           HTTP POST data /形式:key1=value1&key2=value2,也可以指定本地文件,使用-d会自动转为POST请求
  • -f, --fail                 Fail fast with no output on HTTP errors /连接失败时不显示http错误
  • -i, --include              Include protocol response headers in the output /输出相应头信息
  • -o, --output         Write to file instead of stdout /给文件起个别名
  • -O, --remote-name          Write output to a file named as the remote file /需要下载的url, 默认最后部分当作文件名
  • -s, --silent               Silent mode /参数将不输出错误和进度信息
  • -T, --upload-file   Transfer local FILE to destination /用于本地文件上传
  • -u, --user user:password Server user and password /用户的账号密码
  • -A, --user-agent     Send User-Agent to server /修改请求的User-Agent
  • -v, --verbose              Make the operation more talkative /显示通信过程,用于调试
  • -V, --version              Show version number and quit /输出版本号
  • -C/--continue-at ** Resumed transfer offset /断点续传。是一个数值,表示从文件头开始计算的要跳过的字节数、被设定为破折号 -,那么命令将自行检测待传输文件的断点位置
  • -H --header header/@file Pass custom header(s) to server /为 HTTP 数据包指定 Header 字段内容
  • -G, --get                Put the post data in the URL and use GET /指定为GET请求
  • -x/--proxy <proxyhost[:port]>**     为数据传输指定代理服务器。如果没有显示指定端口号,则使用默认端口号1080