使用CURL和编码的URL删除

cof*_*fee 52 url encoding curl request http-delete

我正在尝试使用CURL这样的请求:

curl -X DELETE "https://myhost/context/path/users/OXYugGKg207g5uN/07V" 
Run Code Online (Sandbox Code Playgroud)

哪里OXYugGKg207g5uN/07V是哈希,所以我想我需要在执行此请求之前进行编码.

我试过了 curl -X DELETE --data-urlenconded "https://myhost/context/path/users/OXYugGKg207g5uN/07V"

一些想法?

knu*_*gie 18

试试这个

curl -X DELETE "https://myhost/context/path/users/$(echo -ne "OXYugGKg207g5uN/07V" | xxd -plain | tr -d '\n' | sed 's/\(..\)/%\1/g')"
Run Code Online (Sandbox Code Playgroud)

它是等价的

curl -X DELETE "https://myhost/context/path/users/%4f%58%59%75%67%47%4b%67%32%30%37%67%35%75%4e%2f%30%37%56"
Run Code Online (Sandbox Code Playgroud)

在这里,每个字符都被其字节表示替换......我认为它不是特别漂亮,但它有效.


ark*_*cha 12

如果真的OXYugGKg207g5uN/07V是哈希那么你需要编码,而不是整个网址.您可以在使用cURL的环境中使用可用的编码功能.