因此,我尝试在我的 Mac 上下载一个文件,但获取该文件的要求非常严格:
Username: testx
Password: testing123
Authorization
You can craft the HTTP GET request using a tool such as Fiddler and then use this request in your own custom solution.
- You cannot pass the username and password in via the URL or access the feed through a browser.
- The outgoing HTTP GET request header must contain the Basic Authorization key-value.
For example:
User-Agent: Fiddler
Host: test.test.com
Connection: keep-alive
Authorization: Basic ZmVlALCzABI6VEKABCDzdHIzM3I=
Cache-Control: no-cache
在 Mac 上,我可以使用什么解决方案或程序来获取此文件。我尝试制作 wget 请求,但无法使其工作。Fiddler 似乎在 Mac 上不可用。
答案1
这是一个很容易解决的情况。使用 Wget:
wget --user=testx --password=testing123 --auth-no-challenge example.com
创建以下 HTTP 请求:
GET / HTTP/1.1
User-Agent: Wget/1.16.3.42-5666-dirty (linux-gnu)
Accept: */*
Accept-Encoding: identity
Authorization: Basic dGVzdHg6dGVzdGluZzEyMw==
Host: example.com
Connection: Keep-Alive
这看起来很像您所要求的。