includes/http.php
changeset 1086 6a59951b70e4
parent 1081 745200a9cc2a
child 1113 000791abdc7e
equal deleted inserted replaced
1085:3343a05e7e5b 1086:6a59951b70e4
   195    * @param int Optional. The port to open the request on. Defaults to 80.
   195    * @param int Optional. The port to open the request on. Defaults to 80.
   196    */
   196    */
   197   
   197   
   198   function Request_HTTP($host, $uri, $method = 'GET', $port = 80)
   198   function Request_HTTP($host, $uri, $method = 'GET', $port = 80)
   199   {
   199   {
   200     if ( !preg_match('/^(([a-z0-9-]+\.)*?)([a-z0-9-]+)$/', $host) )
   200     if ( !preg_match('/^(?:(([a-z0-9-]+\.)*?)([a-z0-9-]+)|\[[a-f0-9:]+\])$/', $host) )
   201       throw new Exception(__CLASS__ . ': Invalid hostname');
   201       throw new Exception(__CLASS__ . ': Invalid hostname');
       
   202     // Yes - this really does support IPv6 URLs!
   202     $this->host = $host;
   203     $this->host = $host;
   203     $this->uri = $uri;
   204     $this->uri = $uri;
   204     if ( is_int($port) && $port >= 1 && $port <= 65535 )
   205     if ( is_int($port) && $port >= 1 && $port <= 65535 )
   205       $this->port = $port;
   206       $this->port = $port;
   206     else
   207     else