
所以我試圖在我的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
這看起來很像你所要求的。