body參數 curl post_如何使用cURL发送带有正文,标头和HTTP参数的POST?

声誉不足,无法发表评论,因此请留下答案以希望有所帮助。

curl -L -v --post301 --post302 -i -X PUT -T "${aclfile}" \

-H "Date: ${dateValue}" \

-H "Content-Type: ${contentType}" \

-H "Authorization: AWS ${s3Key}:${signature}" \

${host}:${port}${resource}

这就是我用于S3存储桶acl put操作的内容。标题位于-H中,而作为XML文件的主体位于-T之后的$ {aclfile}中。您可以从输出中看到:

/aaa/?acl

* About to connect() to 192.168.57.101 port 80 (#0)

* Trying 192.168.57.101...

* Connected to 192.168.57.101 (192.168.57.101) port 80 (#0)

> PUT /aaa/?acl HTTP/1.1

> User-Agent: curl/7.29.0

> Host: 192.168.57.101

> Accept: */*

> Date: Thu, 18 Aug 2016 08:01:44 GMT

> Content-Type: application/x-www-form-urlencoded; charset=utf-8

> Authorization: AWS WFBZ1S6SO0DZHW2LRM6U:r84lr/lPO0JCpfk5M3GRJfHdUgQ=

> Content-Length: 323

> Expect: 100-continue

>

< HTTP/1.1 100 CONTINUE

HTTP/1.1 100 CONTINUE

* We are completely uploaded and fine

< HTTP/1.1 200 OK

HTTP/1.1 200 OK

< x-amz-request-id: tx00000000000000000001f-0057b56b69-31d42-default

x-amz-request-id: tx00000000000000000001f-0057b56b69-31d42-default

< Content-Type: application/xml

Content-Type: application/xml

< Content-Length: 0

Content-Length: 0

< Date: Thu, 18 Aug 2016 08:01:45 GMT

Date: Thu, 18 Aug 2016 08:01:45 GMT

<

* Connection #0 to host 192.168.57.101 left intact

如果url参数包含特殊符号(例如“ +”),请对每个参数(包含特殊符号)使用--data-urlencode:

curl -G -H "Accept:..." -H "..." --data-urlencode "beginTime=${time}+${zone}" --data-urlencode "endTime=${time}+${zone}" "${url}"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值