Reputation: 3578
I need this in Ruby:
$context = stream_context_create(array(
'http' => array(
'header' => "Authorization: Basic " . base64_encode("user:pass")
)
));
$output = file_get_contents("http://example.com/file.php", false, $context);
Thanks.
Upvotes: 1
Views: 327
Reputation: 15276
Check out Net::HTTP.
require 'net/http'
output = nil
Net::HTTP.start('example.com') {|http|
req = Net::HTTP::Get.new('/file.php')
req.basic_auth 'user', 'pass'
response = http.request(req)
output = response.body
}
Upvotes: 2