<?php
require_once 'HTTP/Request.php';
/**
* Concrete web page transport
* Fetches page using PEAR::HTTP_Request class. Use this ttansport if you have proxy access and so on.
* Check additional docs for HTTP_Request class.
*
* Use this class under GPL license
* @author Eugene Panin <hide@address.com>, Lubertsy, Russia, 2004
* @home http://www.tortuga.pp.ru/index.php/processor/index/lang/en
* @package mtfetcher
* @depends PEAR (http://pear.php.net), PEAR::HTTP_Request (http://pear.php.net/package/HTTP_Request)
* @version 1.0
*/
class mtfetcher_Transport_PEAR_Request extends mtfetcher_Transport {
/**
* Fetches web page from indicated URL
*
* @param string $url URL of web page
* @return string Web page
* @throws object mtfetcher_Error
* @access public
*/
function getPage($url) {
if (!array_key_exists('method',$this->_conf)) $this->_conf['method'] = 'GET';
$this->_conf['save_body'] = true;
$req = new HTTP_Request($url,$this->_conf);
// Sending request
$err = $req->sendRequest();
if (PEAR::isError($err)) return $err;
// Getting page text
$respCode = $req->getResponseCode();
if ($respCode == 200) {
$resp = $req->getResponseBody();
return $resp;
} // if respCode
return new mtfetcher_CantFetch_Error('Cant fetch web page at '.$url);
} // getPage
} // class
?>