curl命令详解

本文介绍了Curl命令的基本用法及各种选项的作用,包括如何指定HTTP请求方法、请求头、请求数据等。此外还展示了如何使用Curl进行DELETE操作,并提到了Postman作为另一种测试工具。


curl -X DELETE "https://myhost/context/path/users/$(echo -ne "OXYugGKg207g5uN/07V" | xxd -plain | tr -d '\n' | sed 's/\(..\)/%\1/g')"
curl -X DELETE 'http://localhost:5000/locations?id=3'
curl -i -b auth -H "" -X POST
curl http://localhost:5000/todos/todo2 -X DELETE -v
我一般是用curl命令进行测试,除此之外,还可以使用Chrome浏览器的postman扩展。
https://gold.xitu.io/entry/5754ec05816dfa005f7bc01b
选项 作用
-X 指定HTTP请求方法,如POST,GET
-H 指定请求头,例如Content-type:application/json
-d 指定请求数据
--data-binary 指定发送的文件
-i 显示响应头部信息
-u 指定认证用户名与密码
-v 输出请求头部信息


http://www.voidcn.com/blog/Qidi_Huang/article/p-6136742.html
http://usench.iteye.com/blog/2268844
http://www.linuxdiyf.com/linux/2800.html
http://www.ruanyifeng.com/blog/2011/09/curl.html
http://stormzhang.com/devtools/2014/11/07/use-curl-debug/


http://stackoverflow.com/questions/13371284/curl-command-line-url-parameters
curl -X DELETE -G 'http://localhost:5000/locations' -d 'id=3'
curl -X DELETE -G \
'http://localhost:5000/locations' \
-d id=3 \
-d name=Mario \
-d surname=Bros


https://github.com/micha/resty
source resty [-W] [remote]              # load functions into shell
  resty [-v]                              # prints current request URI base
  resty <remote> [OPTIONS]                # sets the base request URI


  HEAD [path] [OPTIONS]                   # HEAD request
  OPTIONS [path] [OPTIONS]                # OPTIONS request
  GET [path] [OPTIONS]                    # GET request
  DELETE [path] [OPTIONS]                 # DELETE request
  PUT [path] [data] [OPTIONS]             # PUT request
  PATCH [path] [data] [OPTIONS]           # PATCH request
  POST [path] [data] [OPTIONS]            # POST request
  TRACE [path] [OPTIONS]                  # TRACE request


  Options:


  -Q            Don't URL encode the path.
  -q <query>    Send query string with the path. A '?' is prepended to
                <query> and concatenated onto the <path>.
  -W            Don't write to history file (only when sourcing script).
  -V            Edit the input data interactively in 'vi'. (PUT, PATCH,
                and POST requests only, with data piped to stdin.)
  -Z            Raw output. This disables any processing of HTML in the
                response.
  -v            Verbose output. When used with the resty command itself
                this prints the saved curl options along with the current
                URI base. Otherwise this is passed to curl for verbose
                curl output.
  --dry-run     Just output the curl command.
  <curl opt>    Any curl options will be passed down to curl.



评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值