bug in stream.php

Fixed and closed topics
Locked
Superlexx
User
Posts: 45
Joined: Thu Feb 10, 2005 8:51 pm

bug in stream.php

Post 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.
User avatar
wbartels
netjukebox developer
Posts: 872
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Post 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
Superlexx
User
Posts: 45
Joined: Thu Feb 10, 2005 8:51 pm

Post 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.
User avatar
wbartels
netjukebox developer
Posts: 872
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Post 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
Locked