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


竟然已经看到这里了,你我定是有缘人,留下你的点赞关注,他日必成大器。

微信公众号:万猫学社

微信扫描二维码

关注后回复「电子书」

获取12本Java必读技术书籍

curl的HTTP参数速查表的更多相关文章

  1. Bash中文速查表

    最好用的中文速查表(Cheatsheet) 来源:https://github.com/skywind3000/awesome-cheatsheets 感谢网友们的贡献! ############## ...

  2. vim基本命令速查表

    来源:https://github.com/skywind3000/awesome-cheatsheets/blob/master/editors/vim.txt ################## ...

  3. bash基本命令速查表

    来源:https://github.com/skywind3000/awesome-cheatsheets/blob/master/languages/bash.sh ################ ...

  4. .htaccess下Flags速查表

    Flags是可选参数,当有多个标志同时出现时,彼此间以逗号分隔. 速查表: RewirteRule 标记 含义 描述 R Redirect 发出一个HTTP重定向 F Forbidden 禁止对URL ...

  5. HTML5速查表

    HTML5速查表 标签 描述 版本 属性 <!--...--> 定义注释 4 / 5 none <!DOCTYPE> 定义文档类型 4 / 5 none <a> 定 ...

  6. Java, C#, Swift语法对比速查表

    原文:Java, C#, Swift语法对比速查表   Java 8 C# 6 Swift 变量 类型 变量名; 类型 变量名; var 变量名 : 类型; 变量(类型推断) N/A var 变量名= ...

  7. Git 常用命令速查表(图文+表格)

    一. Git 常用命令速查 git branch 查看本地所有分支git status 查看当前状态 git commit 提交 git branch -a 查看所有的分支git branch -r ...

  8. 【转】shell速查表

    shell速查表 转自:https://www.jianshu.com/p/a98a334bfb25 1. 变量 #!/bin/bash msg="hello world" ech ...

  9. GNU Emacs命令速查表

    GNU Emacs命令速查表 第一章  Emacs的基本概念 表1-1:Emacs编辑器的主模式 模式 功能 基本模式(fundamental mode) 默认模式,无特殊行为 文本模式(text m ...

随机推荐

  1. 《剑指offer》面试题67. 把字符串转换成整数

    问题描述 写一个函数 StrToInt,实现把字符串转换成整数这个功能.不能使用 atoi 或者其他类似的库函数.   首先,该函数会根据需要丢弃无用的开头空格字符,直到寻找到第一个非空格的字符为止. ...

  2. JVM完整详解:内存分配+运行原理+回收算法+GC参数等

    不管是BAT面试,还是工作实践中的JVM调优以及参数设置,或者内存溢出检测等,都需要涉及到Java虚拟机的内存模型.内存分配,以及回收算法机制等,这些都是必考.必会技能. JVM内存模型 JVM内存模 ...

  3. vue3源码node的问题

    下载vue3源码后,下载依赖时,node的版本需要在10.0.0以上,并且不同的vue3里面的插件的配置对版本依赖还不同,14.0.0以上的版本基本都不支持win7了, win7系统可以安装12.0. ...

  4. Qt之简单绘图实现

    效果图:                                              可以实现打开图片,在打开的图片上画图,可以保存图片,以及橡皮擦,画笔调大调粗换色功能. 代码: XI ...

  5. ansible roles实践 zookeeper集群部署

    1.下载解压 wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.11/zookeeper-3.4.11. ...

  6. 大厂面试:一个四年多经验程序员的BAT面经(字节、阿里、腾讯)

    前言 上次写了篇欢聚时代的面经,公众号后台有些读者反馈说看的意犹未尽,希望我尽快更新其他大厂的面经,这里先说声抱歉,不是我太懒,而是项目组刚好有个活动要赶在春节前上线,所以这几天经常加班,只能工作之余 ...

  7. Nginx配置文件nginx.conf有哪些属性模块?

    worker_processes 1: # worker进程的数量 events { # 事件区块开始 worker_connections 1024: # 每个worker进程支持的最大连接数 } ...

  8. 学习Java第16天

    今天学习了HTML的表格,列表标签及表单. 顺序有点乱,明天学习swing awt,当时这部分大概过了一下,明天看视频 主要问题还是新概念较多,需要多理解,多记忆.

  9. dp学习(六)

    高级科技. 26. 虚树 27. 长链剖分优化dp 28. 插头dp

  10. 【故障公告】数据库服务器 CPU 100% 引发全站故障

    今天 11:12-12:03 期间,园子使用的阿里云 RDS 实例(SQL Server2016 标准版,16核CPU)出现 CPU 100% 问题,引发全站故障,由此给您带来麻烦,请您谅解. 发现故 ...