DELETE使用curl与编码的URL(DELETE using CURL with encoded

2019-08-01 04:25发布

我试图让使用curl这样的要求:

curl -X DELETE "https://myhost/context/path/users/OXYugGKg207g5uN/07V" 

其中OXYugGKg207g5uN/07V是一个哈希,所以我想,我需要编码之前做到这一点的要求。

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

一些想法?

Answer 1:

如果真的OXYugGKg207g5uN/07V是哈希那么你需要编码,而不是整个网址。 您可以使用您提供在使用卷曲的环境内的编码功能。



Answer 2:

试试这个

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

据equivilent到

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"

在这里,每一个字符由它的字节respresentation更换...我不认为这是特别漂亮,但它的工作原理。



文章来源: DELETE using CURL with encoded URL