Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into markup
Browse files Browse the repository at this point in the history
Conflicts:
	library/Zend/Markup/Parser/Textile.php
	library/Zend/Markup/Renderer/AbstractRenderer.php
	library/Zend/Markup/Renderer/Html.php
  • Loading branch information
kokx committed Oct 30, 2010
2 parents c97e7ec + 453bb28 commit 634bb62
Show file tree
Hide file tree
Showing 46 changed files with 510 additions and 153 deletions.
39 changes: 19 additions & 20 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* @category Zend
* @package Zend_Http
* @subpackage Client
* @version $Id$
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
Expand Down Expand Up @@ -257,14 +256,14 @@ public function setUri($uri)
if (is_string($uri)) {
try {
$uri = new Uri\Url($uri);
} catch (URI\Exception $e) {
} catch (Uri\Exception $e) {
throw new Client\Exception('Passed parameter is not a valid HTTP URI.');
}
}

$scheme = strtolower($uri->getScheme());
if (!empty($scheme) && !in_array($scheme, array('http', 'https'))) {
throw new Client\Exception('Passed parameter is not a valid HTTP URI.');
throw new Client\Exception\InvalidArgumentException('Passed parameter is not a valid HTTP URI.');
}

// Set auth if username and password has been specified in the uri
Expand Down Expand Up @@ -310,7 +309,7 @@ public function setConfig($config = array())
$config = $config->toArray();

} elseif (! is_array($config)) {
throw new Client\Exception('Array or Zend_Config object expected, got ' . gettype($config));
throw new Client\Exception\InvalidArgumentException('Array or Zend_Config object expected, got ' . gettype($config));
}

foreach ($config as $k => $v) {
Expand Down Expand Up @@ -339,7 +338,7 @@ public function setConfig($config = array())
public function setMethod($method = self::GET)
{
if (! preg_match('/^[^\x00-\x1f\x7f-\xff\(\)<>@,;:\\\\"\/\[\]\?={}\s]+$/', $method)) {
throw new Client\Exception("'{$method}' is not a valid HTTP request method.");
throw new Client\Exception\InvalidArgumentException("'{$method}' is not a valid HTTP request method.");
}

if ($method == self::POST && $this->enctype === null) {
Expand Down Expand Up @@ -389,7 +388,7 @@ public function setHeaders($name, $value = null)

// Make sure the name is valid if we are in strict mode
if ($this->config['strict'] && (! preg_match('/^[a-zA-Z0-9-]+$/', $name))) {
throw new Client\Exception("{$name} is not a valid HTTP header name");
throw new Client\Exception\InvalidArgumentException("{$name} is not a valid HTTP header name");
}

$normalized_name = strtolower($name);
Expand Down Expand Up @@ -544,7 +543,7 @@ public function setAuth($user, $password = '', $type = self::AUTH_BASIC)
} else {
// Check we got a proper authentication type
if (! defined('self::AUTH_' . strtoupper($type))) {
throw new Client\Exception("Invalid or not supported authentication type: '$type'");
throw new Client\Exception\InvalidArgumentException("Invalid or not supported authentication type: '$type'");
}

$this->auth = array(
Expand Down Expand Up @@ -576,7 +575,7 @@ public function setCookieJar($cookiejar = true)
} elseif (! $cookiejar) {
$this->cookiejar = null;
} else {
throw new Client\Exception('Invalid parameter type passed as CookieJar');
throw new Client\Exception\InvalidArgumentException('Invalid parameter type passed as CookieJar');
}

return $this;
Expand Down Expand Up @@ -636,7 +635,7 @@ public function setCookie($cookie, $value = null)
}

if (preg_match("/[=,; \t\r\n\013\014]/", $cookie)) {
throw new Client\Exception("Cookie name cannot contain these characters: =,; \t\r\n\013\014 ({$cookie})");
throw new Client\Exception\RuntimeException("Cookie name cannot contain these characters: =,; \t\r\n\013\014 ({$cookie})");
}

$value = addslashes($value);
Expand Down Expand Up @@ -674,7 +673,7 @@ public function setFileUpload($filename, $formname, $data = null, $ctype = null)
{
if ($data === null) {
if (($data = @file_get_contents($filename)) === false) {
throw new Client\Exception("Unable to read file '{$filename}' for upload");
throw new Client\Exception\RuntimeException("Unable to read file '{$filename}' for upload");
}

if (! $ctype) {
Expand Down Expand Up @@ -810,13 +809,13 @@ public function setAdapter($adapter)
{
if (is_string($adapter)) {
if (!class_exists($adapter)) {
throw new Client\Exception('Unable to locate adapter class "' . $adapter . '"');
throw new Client\Exception\InvalidArgumentException('Unable to locate adapter class "' . $adapter . '"');
}
$adapter = new $adapter;
}

if (! $adapter instanceof Client\Adapter) {
throw new Client\Exception('Passed adapter is not a HTTP connection adapter');
throw new Client\Exception\InvalidArgumentException('Passed adapter is not a HTTP connection adapter');
}

$this->adapter = $adapter;
Expand Down Expand Up @@ -874,7 +873,7 @@ protected function _openTempStream()
if ($this->adapter instanceof Client\Adapter) {
$this->adapter->close();
}
throw new Client\Exception("Could not open temp file {$this->_stream_name}");
throw new Client\Exception\RuntimeException("Could not open temp file {$this->_stream_name}");
}

return $fp;
Expand All @@ -890,7 +889,7 @@ protected function _openTempStream()
public function request($method = null)
{
if (! $this->uri instanceof Uri\Url) {
throw new Client\Exception('No valid URI has been passed to the client');
throw new Client\Exception\RuntimeException('No valid URI has been passed to the client');
}

if ($method) {
Expand Down Expand Up @@ -923,7 +922,7 @@ public function request($method = null)

// check that adapter supports streaming before using it
if(is_resource($body) && !($this->adapter instanceof Client\Adapter\Stream)) {
throw new Client\Exception('Adapter does not support streaming');
throw new Client\Exception\RuntimeException('Adapter does not support streaming');
}

// Open the connection, send the request and read the response
Expand All @@ -935,7 +934,7 @@ public function request($method = null)
$stream = $this->_openTempStream();
$this->adapter->setOutputStream($stream);
} else {
throw new Client\Exception('Adapter does not support streaming');
throw new Client\Exception\RuntimeException('Adapter does not support streaming');
}
}

Expand All @@ -944,7 +943,7 @@ public function request($method = null)

$response = $this->adapter->read();
if (! $response) {
throw new Client\Exception('Unable to read response, or response is empty');
throw new Client\Exception\RuntimeException('Unable to read response, or response is empty');
}

if($this->config['output_stream']) {
Expand Down Expand Up @@ -1180,7 +1179,7 @@ protected function _prepareBody()
mb_internal_encoding($mbIntEnc);
}

throw new Client\Exception("Cannot handle content type '{$this->enctype}' automatically." .
throw new Client\Exception\RuntimeException("Cannot handle content type '{$this->enctype}' automatically." .
" Please use Zend_Http_Client::setRawData to send this kind of content.");
break;
}
Expand Down Expand Up @@ -1339,7 +1338,7 @@ public static function encodeAuthHeader($user, $password, $type = self::AUTH_BAS
case self::AUTH_BASIC:
// In basic authentication, the user name cannot contain ":"
if (strpos($user, ':') !== false) {
throw new Client\Exception("The user name cannot contain ':' in 'Basic' HTTP authentication");
throw new Client\Exception\InvalidArgumentException("The user name cannot contain ':' in 'Basic' HTTP authentication");
}

$authHeader = 'Basic ' . base64_encode($user . ':' . $password);
Expand All @@ -1352,7 +1351,7 @@ public static function encodeAuthHeader($user, $password, $type = self::AUTH_BAS
// break;

default:
throw new Client\Exception("Not a supported HTTP authentication type: '$type'");
throw new Client\Exception\InvalidArgumentException("Not a supported HTTP authentication type: '$type'");
}

return $authHeader;
Expand Down
1 change: 0 additions & 1 deletion src/Client/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* @category Zend
* @package Zend_Http
* @subpackage Client_Adapter
* @version $Id$
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
Expand Down
26 changes: 13 additions & 13 deletions src/Client/Adapter/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* @category Zend
* @package Zend_Http
* @subpackage Client_Adapter
* @version $Id$
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
Expand All @@ -25,7 +24,8 @@
* @namespace
*/
namespace Zend\Http\Client\Adapter;
use Zend\Http\Client\Adapter as HTTPAdapter,
use Zend\Http\Client\Adapter as HttpAdapter,
Zend\Http\Client\Adapter\Exception as AdapterException,
Zend\Http\Client;

/**
Expand All @@ -44,7 +44,7 @@
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Curl implements HTTPAdapter, Stream
class Curl implements HttpAdapter, Stream
{
/**
* Parameters array
Expand Down Expand Up @@ -99,7 +99,7 @@ class Curl implements HTTPAdapter, Stream
public function __construct()
{
if (!extension_loaded('curl')) {
throw new Exception('cURL extension has to be loaded to use this Zend\Http\Client adapter');
throw new AdapterException\InitializationException('cURL extension has to be loaded to use this Zend\Http\Client adapter');
}
$this->_invalidOverwritableCurlOptions = array(
CURLOPT_HTTPGET,
Expand Down Expand Up @@ -133,7 +133,7 @@ public function setConfig($config = array())
$config = $config->toArray();

} elseif (! is_array($config)) {
throw new Exception(
throw new AdapterException\InvalidArgumentException(
'Array or Zend\Config\Config object expected, got ' . gettype($config)
);
}
Expand Down Expand Up @@ -227,7 +227,7 @@ public function connect($host, $port = 80, $secure = false)
if (!$this->_curl) {
$this->close();

throw new Exception('Unable to Connect to ' . $host . ':' . $port);
throw new AdapterException\RuntimeException('Unable to Connect to ' . $host . ':' . $port);
}

if ($secure !== false) {
Expand Down Expand Up @@ -259,11 +259,11 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $bo
{
// Make sure we're properly connected
if (!$this->_curl) {
throw new Exception("Trying to write but we are not connected");
throw new AdapterException\RuntimeException("Trying to write but we are not connected");
}

if ($this->_connected_to[0] != $uri->getHost() || $this->_connected_to[1] != $uri->getPort()) {
throw new Exception("Trying to write but we are connected to the wrong host");
throw new AdapterException\RuntimeException("Trying to write but we are connected to the wrong host");
}

// set URL
Expand Down Expand Up @@ -299,7 +299,7 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $bo
}

if (!isset($this->_config['curloptions'][CURLOPT_INFILESIZE])) {
throw new Exception("Cannot set a file-handle for cURL option CURLOPT_INFILE without also setting its size in CURLOPT_INFILESIZE.");
throw new AdapterException\RuntimeException("Cannot set a file-handle for cURL option CURLOPT_INFILE without also setting its size in CURLOPT_INFILESIZE.");
}

if(is_resource($body)) {
Expand Down Expand Up @@ -335,11 +335,11 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $bo

default:
// For now, through an exception for unsupported request methods
throw new Exception("Method currently not supported");
throw new AdapterException\InvalidArgumentException("Method currently not supported");
}

if(is_resource($body) && $curlMethod != CURLOPT_PUT) {
throw new Exception("Streaming requests are allowed only with PUT");
throw new AdapterException\RuntimeException("Streaming requests are allowed only with PUT");
}

// get http version to use
Expand Down Expand Up @@ -391,7 +391,7 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $bo
foreach ((array)$this->_config['curloptions'] as $k => $v) {
if (!in_array($k, $this->_invalidOverwritableCurlOptions)) {
if (curl_setopt($this->_curl, $k, $v) == false) {
throw new Client\Exception(sprintf("Unknown or erroreous cURL option '%s' set", $k));
throw new AdapterException\RuntimeException(sprintf("Unknown or erroreous cURL option '%s' set", $k));
}
}
}
Expand All @@ -409,7 +409,7 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $bo
$request .= $body;

if (empty($this->_response)) {
throw new Client\Exception("Error in cURL request: " . curl_error($this->_curl));
throw new AdapterException\RuntimeException("Error in cURL request: " . curl_error($this->_curl));
}

// cURL automatically decodes chunked-messages, this means we have to disallow the Zend\Http\Response to do it again
Expand Down
7 changes: 2 additions & 5 deletions src/Client/Adapter/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* @category Zend
* @package Zend_Http
* @subpackage Client_Adapter_Exception
* @version $Id$
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
Expand All @@ -33,7 +32,5 @@
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Exception extends \Zend\Http\Client\Exception
{
const READ_TIMEOUT = 1000;
}
interface Exception extends \Zend\Http\Client\Exception
{}
38 changes: 38 additions & 0 deletions src/Client/Adapter/Exception/InitializationException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Http
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/

/**
* @namespace
*/
namespace Zend\Http\Client\Adapter\Exception;

/**
*
* @category Zend
* @package Zend_Application
* @uses \Zend\Http\Client\Adapter\Exception
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class InitializationException
extends \RuntimeException
implements \Zend\Http\Client\Adapter\Exception
{}
38 changes: 38 additions & 0 deletions src/Client/Adapter/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Http
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/

/**
* @namespace
*/
namespace Zend\Http\Client\Adapter\Exception;

/**
*
* @category Zend
* @package Zend_Application
* @uses \Zend\Http\Client\Adapter\Exception
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class InvalidArgumentException
extends \InvalidArgumentException
implements \Zend\Http\Client\Adapter\Exception
{}
Loading

0 comments on commit 634bb62

Please sign in to comment.