Skip to content

Commit

Permalink
Remove _getError(), we've got exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
CloCkWeRX committed Jan 10, 2012
1 parent 714809c commit 448b0f5
Showing 1 changed file with 1 addition and 50 deletions.
51 changes: 1 addition & 50 deletions HTTP/Download2.php
Expand Up @@ -269,10 +269,6 @@ function __construct($params = array())
*/
function setParams($params)
{
$error = $this->_getError();
if ($error !== null) {
return $error;
}
foreach((array) $params as $param => $value){
$method = 'set'. $param;

Expand Down Expand Up @@ -303,10 +299,6 @@ function setParams($params)
*/
function setFile($file, $send_error = true)
{
$error = $this->_getError();
if ($error !== null) {
return $error;
}
$file = realpath($file);
if (!is_file($file)) {
if ($send_error) {
Expand Down Expand Up @@ -360,10 +352,6 @@ function setData($data = null)
*/
function setResource($handle = null)
{
$error = $this->_getError();
if ($error !== null) {
return $error;
}
if (!isset($handle)) {
$this->handle = null;
$this->size = 0;
Expand Down Expand Up @@ -396,10 +384,6 @@ function setResource($handle = null)
*/
function setGzip($gzip = false)
{
$error = $this->_getError();
if ($error !== null) {
return $error;
}
if ($gzip && !PEAR::loadExtension('zlib')){
throw new HTTP_Download2_Exception(
'GZIP compression (ext/zlib) not available.',
Expand Down Expand Up @@ -486,10 +470,6 @@ function setETag($etag = null)
*/
function setBufferSize($bytes = 2097152)
{
$error = $this->_getError();
if ($error !== null) {
return $error;
}
if (0 >= $bytes) {
throw new HTTP_Download2_Exception(
'Buffer size must be greater than 0 bytes ('. $bytes .' given)',
Expand Down Expand Up @@ -590,10 +570,6 @@ function setContentDisposition( $disposition = HTTP_DOWNLOAD2_ATTACHMENT,
*/
function setContentType($content_type = 'application/x-octetstream')
{
$error = $this->_getError();
if ($error !== null) {
return $error;
}
if (!preg_match('/^[a-z]+\w*\/[a-z]+[\w.;= -]*$/', $content_type)) {
throw new HTTP_Download2_Exception(
"Invalid content type '$content_type' supplied.",
Expand Down Expand Up @@ -624,10 +600,6 @@ function setContentType($content_type = 'application/x-octetstream')
*/
function guessContentType()
{
$error = $this->_getError();
if ($error !== null) {
return $error;
}
if (class_exists('MIME_Type') || @include_once 'MIME/Type.php') {
if (PEAR::isError($mime_type = MIME_Type::autoDetect($this->file))) {
throw new HTTP_Download2_Exception($mime_type->getMessage(),
Expand Down Expand Up @@ -670,10 +642,6 @@ function guessContentType()
*/
function send($autoSetContentDisposition = true)
{
$error = $this->_getError();
if ($error !== null) {
return $error;
}
if (headers_sent()) {
throw new HTTP_Download2_Exception(
'Headers already sent.',
Expand Down Expand Up @@ -1213,21 +1181,4 @@ function sleep()
}
}

/**
* Returns and clears startup error
*
* @return NULL|PEAR_Error startup error if one exists
* @access protected
*/
function _getError()
{
$error = null;
if (PEAR::isError($this->_error)) {
$error = $this->_error;
$this->_error = null;
}
return $error;
}
// }}}
}
?>
}

0 comments on commit 448b0f5

Please sign in to comment.