cvs: pear /HTTP_Download Download.php
| From: | Michael Wallner | Date: | Tue, 19 Jul 2005 09:31:51 +0000 |
| Subject: | cvs: pear /HTTP_Download Download.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-33140@lists.php.net to get a copy of this message | ||
mike Tue Jul 19 05:31:51 2005 EDT
Modified files:
/pear/HTTP_Download Download.php
Log:
- improve setParams() and let one specify maxage through it
http://cvs.php.net/diff.php/pear/HTTP_Download/Download.php?r1=1.69&r2=1.70&ty=u
Index: pear/HTTP_Download/Download.php
diff -u pear/HTTP_Download/Download.php:1.69 pear/HTTP_Download/Download.php:1.70
--- pear/HTTP_Download/Download.php:1.69 Mon Jul 18 05:38:36 2005
+++ pear/HTTP_Download/Download.php Tue Jul 19 05:31:49 2005
@@ -17,7 +17,7 @@
* @author Michael Wallner <mike@php.net>
* @copyright 2003-2005 Michael Wallner
* @license http://www.php.net/license/3_0.txt
PHP License 3.0
- * @version CVS: $Id: Download.php,v 1.69 2005/07/18 09:38:36 mike Exp $
+ * @version CVS: $Id: Download.php,v 1.70 2005/07/19 09:31:49 mike Exp $
* @link http://pear.php.net/package/HTTP_Download
*/
@@ -92,7 +92,7 @@
* if you want to send already gzipped data!
*
* @access public
- * @version $Revision: 1.69 $
+ * @version $Revision: 1.70 $
*/
class HTTP_Download
{
@@ -225,7 +225,7 @@
* o 'contentdisposition' => content disposition
* o 'buffersize' => amount of bytes to buffer
* o 'throttledelay' => amount of secs to sleep
- * o 'cachecontrol' => public/private
+ * o 'cachecontrol' => cache privacy and validity
*
* <br />
* 'Content-Disposition' is not HTTP compliant, but most browsers
@@ -258,24 +258,27 @@
function setParams($params)
{
foreach((array) $params as $param => $value){
- if (!method_exists($this, 'set' . $param)) {
+ $method = 'set'. $param;
+ if (!method_exists($this, $method)) {
return PEAR::raiseError(
- "Method 'set$param' doesn't exist.",
+ "Method '$method' doesn't exist.",
HTTP_DOWNLOAD_E_INVALID_PARAM
);
}
- if (strToLower($param) == 'contentdisposition') {
- if (is_array($value)) {
- $disp = $value[0];
- $fname = @$value[1];
- } else {
- $disp = $value;
- $fname = null;
- }
- $e = $this->setContentDisposition($disp, $fname);
- } else {
- $e = $this->{'set' . $param}($value);
+
+ switch (strToLower($param))
+ {
+ case 'contentdisposition':
+ case 'cachecontrol':
+ $e = call_user_func_array(
+ array(&$this, 'set'. $param), (array) $value);
+ break;
+
+ default:
+ $e = $this->$method($value);
+ break;
}
+
if (PEAR::isError($e)) {
return $e;
}