卷曲-如何逃脱<在参数值中 [英] curl - How to escape < in parameter value
问题描述
这是我正在执行的curl命令
Here is the curl command I'm executing
curl -F "context=<http://example.com>" \
-F "Content-Type=text/plain" \
-F "source=file" \
-F "content=@members.nt;type=text/plain" \
http://localhost:8080/openrdf-workbench/repositories/XXX/add
我正在尝试加载openrdf存储库。因为出现<,这给了我一个错误。
字符位于 context参数的值中。
如何转义此<因此curl不会认为我正在尝试将文件内容加载到上下文参数中
I'm trying to load openrdf repository. It gives me an error because there is a "<" character at in the value of "context" parameter. How to escape this "<" so curl does not think that I'm trying to load file content into "context" parameter
curl的错误是:
curl: (26) couldn't open file "http://example.com>"
我试图用\并使用<和%3C
,但没有运气,因为一旦我尝试执行此操作,另一端就会抱怨它没有完全得到 http://example.com
I've tried to escape it with \ and using < and %3C but no luck because as soon as I try to do this then the other end is complaining that it did not get exactly http://example.com
这是从浏览器表单发送的内容
This is what is sent from the browser form
------WebKitFormBoundaryl8CUSIvy5962lwBF
Content-Disposition: form-data; name="baseURI"
------WebKitFormBoundaryl8CUSIvy5962lwBF
Content-Disposition: form-data; name="context"
<http://example.com>
------WebKitFormBoundaryl8CUSIvy5962lwBF
Content-Disposition: form-data; name="Content-Type"
text/plain
------WebKitFormBoundaryl8CUSIvy5962lwBF
Content-Disposition: form-data; name="source"
file
------WebKitFormBoundaryl8CUSIvy5962lwBF
Content-Disposition: form-data; name="content"; filename="members.nt"
Content-Type: application/octet-stream
------WebKitFormBoundaryl8CUSIvy5962lwBF--
有任何建议吗?
推荐答案
您可以使用curl的-form-string
,类似于 -F
,但不解释前导 @
和<
:
You can use curl's --form-string
which is like -F
but doesn't interpret leading @
and <
:
--form-string <name=string>
(HTTP) Similar to --form except that the value string for the named parameter is used literally. Leading '@' and '<' characters, and the ';type=' string in the value have
no special meaning. Use this in preference to --form if there's any possibility that the string value may accidentally trigger the '@' or '<' features of --form.
这篇关于卷曲-如何逃脱<在参数值中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!