cvs: pear /Cache HTTP_Request.php

From: Date: Tue, 28 May 2002 17:42:04 +0000
Subject: cvs: pear /Cache HTTP_Request.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-4213@lists.php.net to get a copy of this message
sebastian Tue May 28 13:42:04 2002 EDT Modified files: /pear/Cache HTTP_Request.php Log: Scratch some itches. Index: pear/Cache/HTTP_Request.php diff -u pear/Cache/HTTP_Request.php:1.1 pear/Cache/HTTP_Request.php:1.2 --- pear/Cache/HTTP_Request.php:1.1 Tue May 28 12:27:59 2002 +++ pear/Cache/HTTP_Request.php Tue May 28 13:42:04 2002 @@ -16,17 +16,16 @@ // | Authors: Fabien MARTY <fabien.marty@free.fr> | // +----------------------------------------------------------------------+ // -// $Id: HTTP_Request.php,v 1.1 2002/05/28 16:27:59 fab Exp $ +// $Id: HTTP_Request.php,v 1.2 2002/05/28 17:42:04 sebastian Exp $ -require_once("Cache/Cache.php"); -require_once("Cache/Error.php"); -require_once("HTTP/Request.php"); - -define("CACHE_HTTP_REQUEST_GROUP_NAME", "cache_http_request"); -define("CACHE_HTTP_REQUEST_SUCCESS_RESPONSE_CODE", 200); -define("CACHE_HTTP_REQUEST_KEEP_LOCAL_COPY", 1); -define("CACHE_HTTP_REQUEST_RETURN_FALSE", 2); -define("CACHE_HTTP_REQUEST_RETURN_PEAR_ERROR", 3); +require_once 'Cache.php'; +require_once 'HTTP/Request.php'; + +define('CACHE_HTTP_REQUEST_GROUP_NAME', 'cache_http_request'); +define('CACHE_HTTP_REQUEST_SUCCESS_RESPONSE_CODE', 200); +define('CACHE_HTTP_REQUEST_KEEP_LOCAL_COPY', 1); +define('CACHE_HTTP_REQUEST_RETURN_FALSE', 2); +define('CACHE_HTTP_REQUEST_RETURN_PEAR_ERROR', 3); /** * HTTP_Request Cache @@ -40,7 +39,7 @@ * Every x hours, the cache is updated. But if the remote site is down, the * local cache copy is keeped (you can also get error messages if you want). * -* So you need this class ! +* So you need this class! * * Cache_HTTP_Request inherits from Cache and use HTTP_Request to access to * the remote file. @@ -50,7 +49,7 @@ * <?php * require_once('Cache/HTTP_Request.php'); * -* $cache = &new Cache_HTTP_Request("http://www.php.net", NULL, "file", NULL, 3600); +* $cache = &new Cache_HTTP_Request('http://www.php.net', NULL, 'file', NULL, 3600); * $cache->sendRequest(); * $remoteFileBody = $cache->getResponseBody(); * @@ -58,7 +57,7 @@ * ?> * * @author Fabien MARTY <fabien.marty@free.fr> -* @version $Id: HTTP_Request.php,v 1.1 2002/05/28 16:27:59 fab Exp $ +* @version $Id: HTTP_Request.php,v 1.2 2002/05/28 17:42:04 sebastian Exp $ * @package Cache */ @@ -137,8 +136,8 @@ if (!isset($params)) $params = array(); if (!isset($containerOptions)) { $containerOptions = array ( - "cache_dir" => "/tmp/", - "filename_prefix" => "cache_" + 'cache_dir' => '/tmp/', + 'filename_prefix' => 'cache_' ); } $this->Cache($container, $containerOptions); @@ -168,7 +167,7 @@ */ function getResponseBody() { - return $this->_data["body"]; + return $this->_data['body']; } /** @@ -180,7 +179,7 @@ */ function getResponseCode() { - return $this->_data["code"]; + return $this->_data['code']; } /** @@ -192,7 +191,7 @@ */ function getResponseHeader() { - return $this->_data["header"]; + return $this->_data['header']; } @@ -259,14 +258,14 @@ return false; break; case CACHE_HTTP_REQUEST_RETURN_PEAR_ERROR: - // We return a PEAR_Error ! - return new Cache_Error("Remote file is not available !"); + // We return a PEAR_Error! + return new Cache_Error('Remote file is not available!'); break; } } else { - echo("Nothing !!!"); - // It's terrible ! The remote server is down and definitively no cache available ! - return new Cache_Error("Remote server down and no cache available !"); + echo('Nothing!!!'); + // It's terrible! The remote server is down and definitively no cache available! + return new Cache_Error('Remote server down and no cache available!'); } } } @@ -288,9 +287,9 @@ $code = $this->_request->getResponseCode(); $header = $this->_request->getResponseHeader(); $this->_data = array( - "body" => $body, - "code" => $code, - "header" => $header + 'body' => $body, + 'code' => $code, + 'header' => $header ); return (($code==CACHE_HTTP_REQUEST_SUCCESS_RESPONSE_CODE) ? true : false); }

« previous php.pear.cvs (#4213) next »