![04f7270c0e792702114a5b8e23575987.png](https://i-blog.csdnimg.cn/blog_migrate/4fe171177842228832e9a64a43c0bffd.jpeg)
前言
curl是利用URL语法在命令行方式下工作的开源文件传输工具。它被广泛应用在Unix、多种Linux发行版中,并且有DOS和Win32、Win64下的移植版本。在日常的开发和问题处理中,经常会使用curl命令来测试http接口,Windows/macOS环境上有很多接口测试的工具比如Postman,但这些工具在Linux平台上使用起来相对不那么便捷。有时候当我们要测试一些外部接口时,当本地无权调用测试路径时,需要将测试建立在Linux平台,除了封装简单的请求代码进行实现外,可通过curl工具实现。当然我们平时接触curl命令最多的地方还是在Linux环境,本来curl作为常用命令应该不用多介绍,但是在使用Jenkins API做数据迁移的过程中发现自己对curl相关的命令还是不熟悉,借这个机会重新梳理一些技巧。
curl命令学习使用小结
更新历史
2020年02月05日 - 初稿
阅读原文 - https://wsgzao.github.io/post/curl/
curl简介
curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP). The command is designed to work without user interaction.
curl offers a busload of useful tricks like proxy support, user authentication, FTP upload, HTTP post, SSL connections, cookies, file transfer resume, Metalink, and more. As you will see below, the number of features will make your head spin!
curl 支持你做很多事情。你可以把 curl 想象成一个精简的命令行网页浏览器。它支持几乎你能想到的所有协议,可以交互访问几乎所有在线内容。唯一和浏览器不同的是,curl 不会渲染接收到的相应信息。
curl常用命令
curl 是一个利用URL语法在命令行下工作的文件传输工具。它支持文件上传和下载,所以是综合传输工具,但按传统,习惯称 curl 为下载工具。其语法格式及常见参数含义如下,
# 语法
curl
curl接口测试
curl 可以很方便地完成对 REST API 的调用场景,比如:设置 Header,指定 HTTP 请求方法,指定 HTTP 消息体,指定权限认证信息等。通过 -v 选项也能输出 REST 请求的所有返回信息。curl 功能很强大,有很多参数,这里列出 REST 测试常用的参数:
[GET
使用curl和Jenkins REST API
# To retrieve the job config.xml
curl -X GET
curl help
[options...
curl练习
![5e1593b9aac8335aed45bc643998b1aa.png](https://i-blog.csdnimg.cn/blog_migrate/c7e7a6ede2df77a5c7ed644b5e5d169a.jpeg)
21 个 curl 命令练习
curl exercises
curl练习答案
参考文章
curl the man page
linux使用curl进行接口测试
cURL笔记