相关疑难解决方法(0)

如何为curl命令urlencode数据?

我正在尝试编写一个用于测试的bash脚本,它接受一个参数并通过curl将其发送到网站.我需要对值进行url编码,以确保正确处理特殊字符.做这个的最好方式是什么?

这是我到目前为止的基本脚本:

#!/bin/bash
host=${1:?'bad host'}
value=$2
shift
shift
curl -v -d "param=${value}" http://${host}/somepath $@
Run Code Online (Sandbox Code Playgroud)

bash shell scripting curl urlencode

300
推荐指数
26
解决办法
30万
查看次数

CURL命令行URL参数

我正在尝试DELETE使用CURL 发送带有url参数的请求.我在做:

curl -H application/x-www-form-urlencoded -X DELETE http://localhost:5000/locations` -d 'id=3'
Run Code Online (Sandbox Code Playgroud)

但是,服务器没有看到参数id = 3.我尝试使用一些GUI应用程序,当我将URL传递为:时http://localhost:5000/locations?id=3,它可以工作.我真的宁愿使用CURL而不是这个GUI应用程序.任何人都可以指出我做错了什么?

curl http

165
推荐指数
2
解决办法
37万
查看次数

如何使用curl POST 对url 参数进行urlencode,但不对正文数据进行urlencode?

当使用类似的东西进行curl POST调用时,... | curl -XPOST --data @- https://example.com/是否也可以在命令行上对一些url参数进行url编码(使用curl本身,而不是bash函数),而不必自己对其进行编码并将它们放入curl的url参数中?

所以我希望 POST Body不进行urlencoded,但 url 参数在同一个curl 命令中进行url 编码。

例如:

echo '{"username":"a","password": [1,2]}' | curl --header "Content-Type: application/json" --request POST -d@- --data-urlencode "filter=." http://localhost:8080
Run Code Online (Sandbox Code Playgroud)

似乎没有做我想做的事,而且我已经对我的https://localhost:8080/网址进行了后缀处理?filter...,当参数需要大量编码时,我宁愿避免使用它。

shell curl

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

curl ×3

shell ×2

bash ×1

http ×1

scripting ×1

urlencode ×1