From 79156ff6bb3877178e0b7ea1284c79641cda1132 Mon Sep 17 00:00:00 2001
From: Paul Harrison <pharrison@mythtv.org>
Date: Thu, 1 Nov 2012 21:34:11 +0000
Subject: [PATCH] mythmusic: Fix streaming radio not being able to connect to
 some streams

This fixes a couple of errors with creating the stream GET request header.
If the path part of the the URI is empty the HTTP/1.1 spec says it should be
specified as "/" and not be empty and the Host request-header field should
contain the port if it is non standard.
---
 mythplugins/mythmusic/mythmusic/shoutcast.cpp |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/mythplugins/mythmusic/mythmusic/shoutcast.cpp b/mythplugins/mythmusic/mythmusic/shoutcast.cpp
index 7aaecc7..2608af8 100644
--- a/mythplugins/mythmusic/mythmusic/shoutcast.cpp
+++ b/mythplugins/mythmusic/mythmusic/shoutcast.cpp
@@ -77,11 +77,19 @@ class ShoutCastRequest
                       "Accept: */*\r\n");
 
         QString path = url.path();
+        QString host = url.host();
+
+        if (path.isEmpty())
+            path = "/";
+
         if (url.hasQuery())
             path += '?' + url.encodedQuery();
 
+        if (url.port() != -1)
+            host += QString(":%1").arg(url.port());
+
         hdr.replace("%PATH%", path);
-        hdr.replace("%HOST%", url.host());
+        hdr.replace("%HOST%", host);
         hdr.replace("%VERSION%", MYTH_BINARY_VERSION);
 
         if (!url.userName().isEmpty() && !url.password().isEmpty()) 
@@ -123,11 +131,19 @@ class IceCastRequest
                       "Accept: */*\r\n");
 
         QString path = url.path();
+        QString host = url.host();
+
+        if (path.isEmpty())
+            path = "/";
+
         if (url.hasQuery())
             path += '?' + url.encodedQuery();
 
+        if (url.port() != -1)
+            host += QString(":%1").arg(url.port());
+
         hdr.replace("%PATH%", path);
-        hdr.replace("%HOST%", url.host());
+        hdr.replace("%HOST%", host);
         hdr.replace("%VERSION%", MYTH_BINARY_VERSION);
 
         if (!url.userName().isEmpty() && !url.password().isEmpty()) 
-- 
1.7.8.6

