Skip to content

Commit

Permalink
http: Fix HLS playback on some servers
Browse files Browse the repository at this point in the history
RPi-Distro/vlc#101

The issue is that the server doesn't like the port number on the end of
the Host line. This is a server fault, but it is legitimate to omit the
port number if it is the default so remove it if that is the case.
  • Loading branch information
jc-kynesim committed Jan 8, 2024
1 parent c71541d commit 89a384d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions modules/access/http/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,17 @@ char *vlc_http_msg_format(const struct vlc_http_msg *m, size_t *restrict lenp,

if (m->status < 0)
{
int hlen = (int)strlen(m->authority);
if (hlen > 4 && strcmp(m->scheme, "https") == 0 && strcmp(m->authority + hlen - 4, ":443") == 0)
hlen -= 4;
else if (hlen > 3 && strcmp(m->scheme, "http") == 0 && strcmp(m->authority + hlen - 3, ":80") == 0)
hlen -= 3;

vlc_memstream_printf(&stream, "%s ", m->method);
if (proxied)
vlc_memstream_printf(&stream, "%s://%s", m->scheme, m->authority);
vlc_memstream_printf(&stream, "%s HTTP/1.1\r\nHost: %s\r\n",
m->path ? m->path : m->authority, m->authority);
vlc_memstream_printf(&stream, "%s HTTP/1.1\r\nHost: %.*s\r\n",
m->path ? m->path : m->authority, hlen, m->authority);
}
else
vlc_memstream_printf(&stream, "HTTP/1.1 %03hd .\r\n", m->status);
Expand Down

0 comments on commit 89a384d

Please sign in to comment.