下面是我正在执行的curl命令
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不认为我试图将文件内容加载到"context”参数中
curl的错误是:
curl: (26) couldn't open file "http://example.com>"
我尝试用\并使用<和%3C来转义它,但是没有运气,因为一旦我尝试这样做,另一端就是抱怨它没有得到确切的http://example.com。
这就是从浏览器表单发送的内容。
------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--
有什么建议吗?
发布于 2014-08-25 11:12:11
您可以使用curl的--form-string
,它类似于-F
,但不解释引导@
和<
--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.
https://stackoverflow.com/questions/25484313
复制相似问题