views:

14

answers:

0

I've got a hardware internet radio player which needs to play a stream which is behind an http auth (standard 401 request).

Unfortunately, the device can't cope with http auth, you can't build the username and password into the link (eg: username:password@http etc - and besides, the server won't accept that) and it plays streams by calling an xml playlist first, which is also behind the barrier. Fortunately, the http auth request is not ssl, which might make things easier.

What the device CAN do, however, is variables within the url. ie: http://my.com/play?123

Rather than pointing directly to the password protected audio server, I thought about bouncing the request off my webhosting Apache/php server and using some kind of redirect (.htaccess with php?) to check the variable against a lookup table of username and password, then somehow think that it was the radio which was authorised.

The problem is, the radio is one IP address, my server is another address (and I don't have root access so no httpd.conf tweaks), and the media server (which I have no control over) is another address.

No problem with the podcast xml - this works great:

<?php
$url = "http://www.example.com/something.xml";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "user:pass");
$xmlResponse = curl_exec($ch);
print_r($xmlResponse);
?>

But of course, this is reading in and serving out again. Not what I want to be doing with large mp3 files - and would probably break their T&C too! So, what about a redirect?

<?php
header("Content-Type: audio/mpeg");
$url = "http://www.example.com/something.mp3";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "user:pass");
curl_exec($ch);
header('Location: ' . $url);
?>

but this just takes me to the authorisation page. Sigh.

I've also looked here: http://stackoverflow.com/questions/1726868/proxy-authentication-http-html-details read this http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html found this http://stackoverflow.com/questions/724599/setting-up-an-apache-proxy-with-authentication

and went quietly mad. Is this something that might even be possible? Thanks.