Passing a URL with brackets to curl
If I try to pass a URL to curl that contains brackets, it fails with an error:
$ curl 'http://www.google.com/?TEST[]=1'
curl: (3) [globbing] illegal character in range specification at pos 29
However, if I escape both brackets, it appears to work:
$ curl 'http://www.google.com/?TEST[]=1'
Interestingly, I use a backslash to escape only the first bracket it fails silently with error code 20497:
$ curl 'http://www.google.com/?TEST[]=1'
$ echo $!
20497
My question is how to fix this for general cases? Is there an argument that will escape URLs automatically, or a description of the characters that need to be escaped before passing to curl?
没关系,我在文档中找到它:
-g/--globoff
This option switches off the "URL globbing parser". When you set this option, you can
specify URLs that contain the letters {}[] without having them being interpreted by curl
itself. Note that these letters are not normal legal URL contents but they should be
encoded according to the URI standard.
链接地址: http://www.djcxy.com/p/1328.html
上一篇: 将文件和关联数据发布到RESTful WebService(最好是JSON)
下一篇: 传递一个带括号的URL来卷曲