使用 curl 调用某个 URL 时,它会简化 URL 中的路径(例如 from /a/../b
to /b
)。我该如何告诉 cUrl 不要这样做?
$ curl -V
curl 7.35.0 (x86_64-pc-linux-gnu) libcurl/7.35.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP
$ curl -v 'localhost/a/../b'
* Rebuilt URL to: localhost/b
答案1
传递--path-as-is
标志:
$ curl --path-as-is 'http://localhost/a/../b'