[vlc-devel] [PATCH] adaptive/http: Fix port insertion into URL if on default port

John Cox jc at kynesim.co.uk
Wed Jan 10 09:15:43 UTC 2024


Fix the URL generation code to avoid adding an explicit port if the
port is the default for the scheme. This is fairly clearly what the
code was originally intended to do.

This fixes the playback of some HLS streams where including the
port number in the Host: field causes the segment fetch to fail
with 404.

Signed-off-by: John Cox <jc at kynesim.co.uk>
---
This looks like a typo in the original code which is obviously
wrong (will only avoid adding the port with https on port 80 or
http on port 443 which is the wrong way round)

Example of a previously failing stream:
https://nrk-od2.telenorcdn.net/open/ps/dnpr/dnpr63701115/d0bc193d-1.smil/sc-gaFEAQ/v4_index.m3u8

 modules/demux/adaptive/http/ConnectionParams.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/demux/adaptive/http/ConnectionParams.cpp b/modules/demux/adaptive/http/ConnectionParams.cpp
index 6e3f221b66..a60239d16d 100644
--- a/modules/demux/adaptive/http/ConnectionParams.cpp
+++ b/modules/demux/adaptive/http/ConnectionParams.cpp
@@ -70,8 +70,8 @@ void ConnectionParams::setPath(const std::string &path_)
     if(!hostname.empty())
     {
         os << hostname;
-        if( (port != 80 && scheme != "http") ||
-            (port != 443 && scheme != "https") )
+        if( (port != 80 && scheme == "http") ||
+            (port != 443 && scheme == "https") )
             os << ":" << port;
     }
     os << path;
-- 
2.40.1



More information about the vlc-devel mailing list