MacでHTTP GETを使ってファイルを取得する

MacでHTTP GETを使ってファイルを取得する

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

これはあなたが求めていたものとほぼ同じです。

関連情報