2, 'Name'=>'cam2', 'Protocol'=>'http', 'Hostname'=>'cam2.example', 'Port'=>null)); check('remote server without port', $s->Url(), 'http://cam2.example'); $s = new Server(array('Id'=>2, 'Name'=>'cam2', 'Protocol'=>'https', 'Hostname'=>'cam2.example', 'Port'=>'')); check('remote https server with empty port', $s->Url(), 'https://cam2.example'); $s = new Server(array('Id'=>2, 'Name'=>'cam2', 'Protocol'=>'http', 'Hostname'=>'cam2.example', 'Port'=>8080)); check('remote server with port', $s->Url(), 'http://cam2.example:8080'); $s = new Server(array('Id'=>2, 'Name'=>'cam2', 'Protocol'=>'http', 'Hostname'=>'cam2.example', 'Port'=>80)); check('remote server default port', $s->Url(), 'http://cam2.example'); # Single server behind a proxy that forwards the host with its port, # with the streaming port in use (ZM_MIN_STREAMING_PORT + monitor id) $_SERVER = array('HTTP_X_FORWARDED_HOST'=>'zm.example:8443', 'HTTP_X_FORWARDED_PROTO'=>'https'); $s = new Server(); check('forwarded host with port and streaming port', $s->Url(30001), 'https://zm.example:30001'); $_SERVER = array('HTTP_X_FORWARDED_HOST'=>'[::1]:8443', 'HTTP_X_FORWARDED_PROTO'=>'https'); check('forwarded ipv6 host with port', $s->Url(30001), 'https://[::1]:30001'); $_SERVER = array('HTTP_X_FORWARDED_HOST'=>'zm.example', 'HTTP_X_FORWARDED_PROTO'=>'https'); check('forwarded host without port', $s->Url(30001), 'https://zm.example:30001'); exit($failures ? 1 : 0);