--- admin.old	2005-09-12 22:50:48.000000000 +0000
+++ admin.c	2006-05-01 21:03:13.000000000 +0000
@@ -685,17 +685,34 @@
 
     client->respcode = 200;
     config = config_get_config();
-    snprintf (client->refbuf->data, PER_CLIENT_REFBUF_SIZE,
-        "HTTP/1.0 200 OK\r\n"
-        "Content-Type: audio/x-mpegurl\r\n"
-        "Content-Disposition = attachment; filename=listen.m3u\r\n\r\n" 
-        "http://%s:%s@%s:%d%s\r\n",
-        username,
-        password,
-        config->hostname,
-        config->port,
-        source->mount
-    );
+    char *host = httpp_getvar (client->parser, "host");
+    if (host && strchr (host, ':') == NULL)
+        host = NULL;
+    if (host == NULL) {
+        snprintf (client->refbuf->data, PER_CLIENT_REFBUF_SIZE,
+            "HTTP/1.0 200 OK\r\n"
+            "Content-Type: audio/x-mpegurl\r\n"
+            "Content-Disposition = attachment; filename=listen.m3u\r\n\r\n"
+            "http://%s:%s@%s:%d%s\r\n",
+            username,
+            password,
+            config->hostname,
+            config->port,
+            source->mount
+        );
+    }
+    else {
+        snprintf (client->refbuf->data, PER_CLIENT_REFBUF_SIZE,
+            "HTTP/1.0 200 OK\r\n"
+            "Content-Type: audio/x-mpegurl\r\n"
+            "Content-Disposition = attachment; filename=listen.m3u\r\n\r\n"
+            "http://%s:%s@%s%s\r\n",
+            username,
+            password,
+            host,
+            source->mount
+        );
+    }
     config_release_config();
 
     client->refbuf->len = strlen (client->refbuf->data);
