encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']); } $this->url = $url; $this->useragent = $useragent; if (preg_match('/^http(s)?:\/\//i', $url)) { if (!is_array($headers)) { $headers = array(); } $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL; $headers2 = array(); foreach ($headers as $key => $value) { $headers2[] = "$key: $value"; } //TODO: allow for HTTP headers // curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2); $response = self::$agent->get($url); if ($response === false || !isset($response['status_code'])) { $this->error = 'failed to fetch URL'; $this->success = false; } else { $parser = new SimplePie_HTTP_Parser($response['headers']); if ($parser->parse()) { $this->headers = $parser->headers; //$this->body = $parser->body; $this->body = $response['body']; $this->status_code = $parser->status_code; } } } else { $this->error = 'invalid URL'; $this->success = false; } } } ?>