Page 1 of 1

bug in stream.php

Posted: Thu Feb 10, 2005 10:09 pm
by Superlexx
Hi,

stream.php, line 59-60:
instead of

Code: Select all

if ($_SERVER['SERVER_PORT'] == 80)	$port = '';
else								$port = ':' . $_SERVER['SERVER_PORT'];
it should be something like

Code: Select all

$port = $_SERVER['SERVER_PORT'] == 80 ? ':80' : '';
because otherwise the port is written twice into the URLs in the playlist.

I doubt this $port thing is needed at all, but I cannot test it ATM.

Posted: Fri Feb 11, 2005 1:38 am
by wbartels
This is not a bug, I have tested streaming from port 80 and another port number.
The port numbers have to be added to all URL’s in the playlist.
This is not necessary for port 80, because this is the default http port number.
See the two examples below:

Streaming from http://www.website.com/netjukebox/ (port 80)

Code: Select all

#EXTM3U
#EXTINF:520,Tosca - Fuck dub part 1+2
http://www.website.com/netjukebox/stream.php?command=stream&track_id=.....
#EXTINF:88,Tosca - Amalienbad
http://www.website.com/netjukebox/stream.php?command=stream&track_id=.....
#EXTINF:363,Tosca - Worksong
#Expire: Fri, 11 Feb 2005 03:02:00 +0100
Streaming from http://www.website.com:1080/netjukebox/

Code: Select all

#EXTM3U
#EXTINF:520,Tosca - Fuck dub part 1+2
http://www.website.com:1080/netjukebox/stream.php?com:1080mand=stream&track_id=.....
#EXTINF:88,Tosca - Amalienbad
http://www.website.com:1080/netjukebox/stream.php?com:1080mand=stream&track_id=.....
#EXTINF:363,Tosca - Worksong
#Expire: Fri, 11 Feb 2005 03:02:00 +0100

Posted: Fri Feb 11, 2005 10:07 am
by Superlexx
http://de2.php.net/manual/en/reserved.v ... les.server :
'HTTP_HOST'

Contents of the Host: header from the current request, if there is one.
http://www.w3.org/Protocols/rfc2616/rfc ... l#sec14.23 :
A "host" without any trailing port information implies the default port for the service requested (e.g., "80" for an HTTP URL).
So when the server is running on a non-standart port, the HTTP client must send something like "Host: localhost:7777" in the headers, which then becomes the value of $_SERVER['HTTP_HOST']. If you do

Code: Select all

echo 'http://' . $_SERVER['HTTP_HOST'] . $port . [...]
, then you get "http://localhost:7777:7777/[...]".

Maybe some buggy HTTP agents don't send the Host: header correctly, well then you have to check first if the $_SERVER['HTTP_HOST'] includes the port.

Posted: Fri Feb 11, 2005 11:29 am
by wbartels
I thought I had tested this a long time ago :oops:
Now I see that $_SERVER['HTTP_HOST'] already gave a port number.

I will fix it in the next version.
The same mistake was made in about.php on line 141 and 142.
I think the best way is to remove these lines from the code.

Thanks very much for your help :D