我正在尝试使用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"
一些想法?
答案 0 :(得分:16)
试试这个
curl -X DELETE "https://myhost/context/path/users/$(echo -ne "OXYugGKg207g5uN/07V" | xxd -plain | tr -d '\n' | sed 's/\(..\)/%\1/g')"
相当于
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"
这里,每个字符都被其字节表示替换...... 不要认为它特别漂亮,但它确实有效。
答案 1 :(得分:11)
如果确实OXYugGKg207g5uN/07V
是哈希值,则需要对其进行编码,而不是整个网址。您可以在使用cURL的环境中使用可用的编码功能。