All remaining files converted from doxygen to PHPDoc, besides IdentityServices.
Partially implements blueprint phpdoc. Change-Id: I838ff99a2b4bb22745c1272a7b20358f802b61ed
This commit is contained in:
parent
38ae1ae3e8
commit
afdafbb959
|
@ -15,7 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
* An Autoloader to use for the case Composer isn't available.
|
||||
*/
|
||||
|
||||
|
@ -30,11 +29,8 @@ namespace OpenStack;
|
|||
*
|
||||
* The autoloader can be used like:
|
||||
*
|
||||
* @code
|
||||
* Autoloader::useAutoloader();
|
||||
* @endcode
|
||||
* Autoloader::useAutoloader();
|
||||
*
|
||||
* @attention
|
||||
* The structure of the OpenStack file hierarchy is PSR-4 compliant.
|
||||
* This means that you can use any standard PSR-4 classloader to
|
||||
* load all of the classes here.
|
||||
|
@ -44,12 +40,12 @@ namespace OpenStack;
|
|||
* classloader that will load JUST the OpenStack classes. See
|
||||
* the Autoloader::useAutoloader() static method.
|
||||
*
|
||||
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4.md
|
||||
* @see https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4.md
|
||||
*/
|
||||
Class Autoloader {
|
||||
|
||||
/**
|
||||
* The directory where OpenStack is located.
|
||||
* @var string The directory where OpenStack is located.
|
||||
*/
|
||||
public static $basedir = __DIR__;
|
||||
|
||||
|
@ -78,10 +74,8 @@ Class Autoloader {
|
|||
* OpenStack::useAutoloader() if you want PHP to automatically
|
||||
* load classes using this autoloader.
|
||||
*
|
||||
* @code
|
||||
* // Enable the autoloader.
|
||||
* Autoloader::useAutoloader();
|
||||
* @endcode
|
||||
* // Enable the autoloader.
|
||||
* Autoloader::useAutoloader();
|
||||
*
|
||||
* This is a special-purpose autoloader for loading
|
||||
* only the OpenStack classes. It will not attempt to
|
||||
|
@ -92,8 +86,7 @@ Class Autoloader {
|
|||
* autoloaders (and also projects that don't
|
||||
* rely upon autoloaders).
|
||||
*
|
||||
* @param string $klass
|
||||
* The fully qualified name of the class to be autoloaded.
|
||||
* @param string $klass The fully qualified name of the class to be autoloaded.
|
||||
*/
|
||||
public static function autoload($klass) {
|
||||
$components = explode('\\', $klass);
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
* OpenStacl PHP-Client configuration.
|
||||
*
|
||||
* It also automatically register the OpenStack stream wrappers.
|
||||
|
@ -31,49 +30,47 @@ use OpenStack\Exception;
|
|||
*
|
||||
* There is no requirement that this class be used. OpenStack is
|
||||
* built to be flexible, and any individual component can be
|
||||
* used directly, with one caveat: No explicit @c require or
|
||||
* @c include calls are made.
|
||||
* used directly, with one caveat: No explicit `require` or
|
||||
* `include` calls are made.
|
||||
*
|
||||
* This class provides the following services:
|
||||
*
|
||||
* - <em>Configuration:</em> "global" settings are set here.
|
||||
* - Configuration: "global" settings are set here.
|
||||
* See the setConfiguration() method to see how they
|
||||
* can be set, and the config() and hasConfig() methods to see
|
||||
* how configuration might be checked.
|
||||
* - <em>Stream Wrappers:</em> This class can initialize a set of stream
|
||||
* - Stream Wrappers: This class can initialize a set of stream
|
||||
* wrappers which will make certain OpenStack services available
|
||||
* through the core PHP stream support.
|
||||
*
|
||||
* <b>Configuration</b>
|
||||
* Configuration
|
||||
*
|
||||
* Configuration directives can be merged into the existing confiuration
|
||||
* using the setConfiguration method.
|
||||
*
|
||||
* @code
|
||||
* <?php
|
||||
* $config = array(
|
||||
* // Use the faster and better CURL transport.
|
||||
* 'transport' => '\OpenStack\Transport\CURLTransport',
|
||||
* // Set the HTTP max wait time to 500.
|
||||
* 'transport.timeout' => 500,
|
||||
* );
|
||||
* Bootstrap::setConfiguration($config);
|
||||
* <?php
|
||||
* $config = array(
|
||||
* // Use the faster and better CURL transport.
|
||||
* 'transport' => '\OpenStack\Transport\CURLTransport',
|
||||
* // Set the HTTP max wait time to 500.
|
||||
* 'transport.timeout' => 500,
|
||||
* );
|
||||
* Bootstrap::setConfiguration($config);
|
||||
*
|
||||
* // Check and get params.
|
||||
* if (Bootstrap::hasConf('transport.timeout') {
|
||||
* $to = Bootstrap::conf('transport.timeout');
|
||||
* }
|
||||
* // Check and get params.
|
||||
* if (Bootstrap::hasConf('transport.timeout') {
|
||||
* $to = Bootstrap::conf('transport.timeout');
|
||||
* }
|
||||
*
|
||||
* // Or get a param with a default value:
|
||||
* $val = Bootstrap::conf('someval', 'default value');
|
||||
* // Or get a param with a default value:
|
||||
* $val = Bootstrap::conf('someval', 'default value');
|
||||
*
|
||||
* // $val will be set to 'default value' because there
|
||||
* // is no 'someval' configuration param.
|
||||
* // $val will be set to 'default value' because there
|
||||
* // is no 'someval' configuration param.
|
||||
*
|
||||
* ?>
|
||||
* @endcode
|
||||
* ?>
|
||||
*
|
||||
* <b>STREAM WRAPPERS</b>
|
||||
* STREAM WRAPPERS
|
||||
*
|
||||
* Stream wrappers allow you to use the built-in file manipulation
|
||||
* functions in PHP to interact with other services. Specifically,
|
||||
|
@ -82,7 +79,6 @@ use OpenStack\Exception;
|
|||
* commands like file_get_contents() and fopen().
|
||||
*
|
||||
* It's awesome. Trust me.
|
||||
*
|
||||
*/
|
||||
class Bootstrap {
|
||||
|
||||
|
@ -91,38 +87,36 @@ class Bootstrap {
|
|||
// wrapper's HTTP mechanism to process transactions.
|
||||
//'transport' => '\OpenStack\Transport\PHPStreamTransport',
|
||||
|
||||
// This is the default transport while a bug persists in the
|
||||
// This is the default transport while a bug persists in the
|
||||
// Identity Services REST service.
|
||||
'transport' => '\OpenStack\Transport\CURLTransport',
|
||||
);
|
||||
|
||||
/**
|
||||
* An identity services object created from the global settings.
|
||||
* @var object OpenStack::Services::IdentityService
|
||||
* @var \OpenStack\Services\IdentityService An identity services object
|
||||
* created from the global settings.
|
||||
*/
|
||||
public static $identity = NULL;
|
||||
|
||||
/**
|
||||
* Register stream wrappers for OpenStack.
|
||||
*
|
||||
* This register the ObjectStorage stream wrappers, which allow you to access
|
||||
* This registers the ObjectStorage stream wrappers, which allow you to access
|
||||
* ObjectStorage through standard file access mechanisms.
|
||||
*
|
||||
* @code
|
||||
* // Enable stream wrapper.
|
||||
* Bootstrap::useStreamWrappers();
|
||||
* // Enable stream wrapper.
|
||||
* Bootstrap::useStreamWrappers();
|
||||
*
|
||||
* // Create a context resource.
|
||||
* $cxt = stream_context_create(array(
|
||||
* 'tenantid' => '12de21',
|
||||
* 'account' => '123454321',
|
||||
* 'secret' => 'f78saf7hhlll',
|
||||
* 'endpoint' => 'https://identity.hpcloud.com' // <-- not real URL!
|
||||
* ));
|
||||
* // Create a context resource.
|
||||
* $cxt = stream_context_create(array(
|
||||
* 'tenantid' => '12de21',
|
||||
* 'account' => '123454321',
|
||||
* 'secret' => 'f78saf7hhlll',
|
||||
* 'endpoint' => 'https://identity.hpcloud.com' // <-- not real URL!
|
||||
* ));
|
||||
*
|
||||
* // Get the contents of a Swift object.
|
||||
* $content = file_get_contents('swift://public/notes.txt', 'r', FALSE, $cxt);
|
||||
* @endcode
|
||||
* // Get the contents of a Swift object.
|
||||
* $content = file_get_contents('swift://public/notes.txt', 'r', FALSE, $cxt);
|
||||
*/
|
||||
public static function useStreamWrappers() {
|
||||
$swift = stream_wrapper_register(
|
||||
|
@ -177,8 +171,7 @@ class Bootstrap {
|
|||
* - proxy.tunnel: If this is set to TRUE, attempt to tunnel through the
|
||||
* proxy. This is recommended when using a proxy. (CURLOPT_HTTPPROXYTUNNEL)
|
||||
*
|
||||
* @param array $array
|
||||
* An associative array of configuration directives.
|
||||
* @param array $array An associative array of configuration directives.
|
||||
*/
|
||||
public static function setConfiguration($array) {
|
||||
self::$config = $array + self::$config;
|
||||
|
@ -189,13 +182,10 @@ class Bootstrap {
|
|||
*
|
||||
* Get a configuration option by name, with an optional default.
|
||||
*
|
||||
* @param string $name
|
||||
* The name of the configuration option to get.
|
||||
* @param mixed $default
|
||||
* The default value to return if the name is not found.
|
||||
* @retval mixed
|
||||
* @return mixed
|
||||
* The value, if found; or the default, if set; or NULL.
|
||||
* @param string $name The name of the configuration option to get.
|
||||
* @param mixed $default The default value to return if the name is not found.
|
||||
*
|
||||
* @return mixed The value, if found; or the default, if set; or NULL.
|
||||
*/
|
||||
public static function config($name = NULL, $default = NULL) {
|
||||
|
||||
|
@ -216,38 +206,33 @@ class Bootstrap {
|
|||
/**
|
||||
* Check whether the given configuration option is set.
|
||||
*
|
||||
* @code
|
||||
* if (Bootstrap::hasConfig('transport')) {
|
||||
* syslog(LOG_INFO, 'An alternate transport is supplied.');
|
||||
* }
|
||||
* @endcode
|
||||
* if (Bootstrap::hasConfig('transport')) {
|
||||
* syslog(LOG_INFO, 'An alternate transport is supplied.');
|
||||
* }
|
||||
*
|
||||
* @param string $name
|
||||
* The name of the item to check for.
|
||||
* @retval boolean
|
||||
* @return boolean
|
||||
* TRUE if the named option is set, FALSE otherwise. Note that the value may
|
||||
* be falsey (FALSE, 0, etc.), but if the value is NULL, this will return
|
||||
* false.
|
||||
* @param string $name The name of the item to check for.
|
||||
*
|
||||
* @return boolean TRUE if the named option is set, FALSE otherwise. Note that
|
||||
* the value may be falsey (FALSE, 0, etc.), but if the value is NULL, this
|
||||
* will return false.
|
||||
*/
|
||||
public static function hasConfig($name) {
|
||||
return isset(self::$config[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a OpenStack::Services::IdentityService object from the bootstrap config.
|
||||
* Get a \OpenStack\Services\IdentityService object from the bootstrap config.
|
||||
*
|
||||
* A factory helper function that uses the bootstrap configuration to create
|
||||
* a ready to use OpenStack::Services::IdentityService object.
|
||||
* a ready to use \OpenStack\Services\IdentityService object.
|
||||
*
|
||||
* @param bool $force
|
||||
* Whether to force the generation of a new object even if one is already
|
||||
* cached.
|
||||
* @retval OpenStack::Services::IdentityService
|
||||
* @return \OpenStack\Services\:IdentityService
|
||||
* An authenticated ready to use OpenStack::Services::IdentityService object.
|
||||
* @throws OpenStack::Exception
|
||||
* When the needed configuration to authenticate is not available.
|
||||
* @param bool $force Whether to force the generation of a new object even if
|
||||
* one is already cached.
|
||||
*
|
||||
* @return \OpenStack\Services\IdentityService An authenticated ready to use
|
||||
* \OpenStack\Services\IdentityService object.
|
||||
* @throws \OpenStack\Exception When the needed configuration to authenticate
|
||||
* is not available.
|
||||
*/
|
||||
public static function identity($force = FALSE) {
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
* The parent exception class for OpenStack.
|
||||
*/
|
||||
namespace OpenStack;
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
* The Transport class.
|
||||
*/
|
||||
namespace OpenStack;
|
||||
|
@ -25,19 +24,17 @@ namespace OpenStack;
|
|||
* Interaction with the OpenStack services is handled via
|
||||
* HTTPS/REST requests. This class provides transport for requests.
|
||||
*
|
||||
* <b>Usage</b>
|
||||
* Usage
|
||||
*
|
||||
* @code
|
||||
* <?php
|
||||
* // Create a new transport.
|
||||
* $client = Transport::instance();
|
||||
* <?php
|
||||
* // Create a new transport.
|
||||
* $client = Transport::instance();
|
||||
*
|
||||
* // Send a request.
|
||||
* $response = $client->doRequest($uri, $method, $headerArray, $body);
|
||||
* // Send a request.
|
||||
* $response = $client->doRequest($uri, $method, $headerArray, $body);
|
||||
*
|
||||
* print $response->content();
|
||||
* ?>
|
||||
* @endcode
|
||||
* print $response->content();
|
||||
* ?>
|
||||
*
|
||||
*/
|
||||
class Transport {
|
||||
|
@ -47,28 +44,24 @@ class Transport {
|
|||
/**
|
||||
* Get an instance of a Transporter.
|
||||
*
|
||||
* See OpenStack::Transport::CURLTransport and OpenStack::Transport::PHPStreamTransport
|
||||
* for implementations of an OpenStack::Transport::Transporter.
|
||||
* @see \OpenStack\Transport\CURLTransport and \OpenStack\Transport\PHPStreamTransport
|
||||
* for implementations of an \OpenStack\Transport\Transporter.
|
||||
*
|
||||
* To set the transport, the suggested method is this:
|
||||
*
|
||||
* @code
|
||||
* <?php
|
||||
* // Set the 'transport' config option.
|
||||
* $settings = array(
|
||||
* // Make sure you use the entire namespace, and that
|
||||
* // your classloader can find this namespace.
|
||||
* 'transport' => '\OpenStack\Transport\CURLTransport',
|
||||
* );
|
||||
* <?php
|
||||
* // Set the 'transport' config option.
|
||||
* $settings = array(
|
||||
* // Make sure you use the entire namespace, and that
|
||||
* // your classloader can find this namespace.
|
||||
* 'transport' => '\OpenStack\Transport\CURLTransport',
|
||||
* );
|
||||
*
|
||||
* // Merge $settings into existing configuration.
|
||||
* \OpenStack\Bootstrap::setConfiguration($settings);
|
||||
* ?>
|
||||
* @endcode
|
||||
* // Merge $settings into existing configuration.
|
||||
* \OpenStack\Bootstrap::setConfiguration($settings);
|
||||
* ?>
|
||||
*
|
||||
* @retval OpenStack::Transport::Transporter
|
||||
* @return \OpenStack\Transport\Transporter
|
||||
* An initialized transporter.
|
||||
* @return \OpenStack\Transport\Transporter An initialized transporter.
|
||||
*/
|
||||
public static function instance() {
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* The authorization exception.
|
||||
*/
|
||||
namespace OpenStack\Transport;
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
* Implements a transporter with CURL.
|
||||
*/
|
||||
|
||||
|
@ -237,7 +236,6 @@ class CURLTransport implements Transporter {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Set all of the curl opts and then execute.
|
||||
curl_setopt_array($curl, $opts);
|
||||
$ret = $this->execCurl($curl);//curl_exec($curl);
|
||||
|
@ -260,7 +258,6 @@ class CURLTransport implements Transporter {
|
|||
Response::failure($status, $err, $info['url'], $method, $info);
|
||||
}
|
||||
|
||||
|
||||
rewind($out);
|
||||
// Now we need to build a response.
|
||||
$resp = new Response($out, $info, $responseHeaders);
|
||||
|
@ -273,7 +270,6 @@ class CURLTransport implements Transporter {
|
|||
return $resp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Poor man's connection pooling.
|
||||
*
|
||||
|
@ -286,12 +282,10 @@ class CURLTransport implements Transporter {
|
|||
* We've noticed that this improves performance substantially, especially since
|
||||
* SSL requests only require the SSL handshake once.
|
||||
*
|
||||
* @param resource $handle
|
||||
* A CURL handle from curl_init().
|
||||
* @retval boolean
|
||||
* @return boolean
|
||||
* Returns a boolean value indicating whether or not CURL could process the
|
||||
* request.
|
||||
* @param resource $handle A CURL handle from curl_init().
|
||||
*
|
||||
* @return boolean Returns a boolean value indicating whether or not CURL
|
||||
* could process the request.
|
||||
*/
|
||||
protected function execCurl($handle) {
|
||||
if (empty($this->multi)) {
|
||||
|
@ -332,11 +326,9 @@ class CURLTransport implements Transporter {
|
|||
* This format mataches the format returned by the stream handlers, so
|
||||
* we can re-use the header parsing logic in Response.
|
||||
*
|
||||
* @param resource $file
|
||||
* A file pointer to the file that has the headers.
|
||||
* @retval array
|
||||
* @return array
|
||||
* An array of headers, one header per line.
|
||||
* @param resource $file A file pointer to the file that has the headers.
|
||||
*
|
||||
* @return array An array of headers, one header per line.
|
||||
*/
|
||||
protected function fetchHeaders($file) {
|
||||
$buffer = array();
|
||||
|
@ -356,15 +348,13 @@ class CURLTransport implements Transporter {
|
|||
/**
|
||||
* Set the appropriate constant on the CURL object.
|
||||
*
|
||||
* Curl handles method name setting in a slightly counter-intuitive
|
||||
* way, so we have a special function for setting the method
|
||||
* correctly. Note that since we do not POST as www-form-*, we
|
||||
* Curl handles method name setting in a slightly counter-intuitive
|
||||
* way, so we have a special function for setting the method
|
||||
* correctly. Note that since we do not POST as www-form-*, we
|
||||
* use a custom post.
|
||||
*
|
||||
* @param resource $curl
|
||||
* A curl object.
|
||||
* @param string $method
|
||||
* An HTTP method name.
|
||||
* @param resource $curl A curl object.
|
||||
* @param string $method An HTTP method name.
|
||||
*/
|
||||
protected function determineMethod($curl, $method) {
|
||||
$method = strtoupper($method);
|
||||
|
|
|
@ -14,9 +14,7 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
namespace OpenStack\Transport;
|
||||
/**
|
||||
* Represents an HTTP 409 error.
|
||||
|
|
|
@ -14,9 +14,7 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
namespace OpenStack\Transport;
|
||||
/**
|
||||
* Represents an HTTP File Not Found error.
|
||||
|
|
|
@ -14,9 +14,7 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
namespace OpenStack\Transport;
|
||||
/**
|
||||
* Represents an HTTP 412 error.
|
||||
|
|
|
@ -14,9 +14,7 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
namespace OpenStack\Transport;
|
||||
/**
|
||||
* Represents an HTTP 405 error.
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
* Implements a transporter with the PHP HTTP Stream Wrapper.
|
||||
*/
|
||||
|
||||
|
@ -34,10 +33,10 @@ namespace OpenStack\Transport;
|
|||
*
|
||||
* You can use a single PHPStreamTransport object to execute multiple requests.
|
||||
*
|
||||
* @attention This class should not be constructed directly.
|
||||
* Use OpenStack::Transport::instance() to get an instance.
|
||||
* This class should not be constructed directly.
|
||||
* Use \OpenStack\Transport::instance() to get an instance.
|
||||
*
|
||||
* See OpenStack::Transport and OpenStack::Bootstrap.
|
||||
* @see \OpenStack\Transport and \OpenStack\Bootstrap.
|
||||
*/
|
||||
class PHPStreamTransport implements Transporter {
|
||||
|
||||
|
@ -184,8 +183,8 @@ class PHPStreamTransport implements Transporter {
|
|||
* of notifications. This function can be used to register an event
|
||||
* handler to listen for notifications.
|
||||
*
|
||||
* @param callable $callable
|
||||
* Any callable, including an anonymous function or closure.
|
||||
* @param callable $callable Any callable, including an anonymous function or
|
||||
* closure.
|
||||
*
|
||||
* @see http://us3.php.net/manual/en/function.stream-notification-callback.php
|
||||
*/
|
||||
|
@ -199,11 +198,9 @@ class PHPStreamTransport implements Transporter {
|
|||
* This builds an HTTP header string in the form required by the HTTP stream
|
||||
* wrapper for PHP.
|
||||
*
|
||||
* @param array $headers
|
||||
* An associative array of header names to header values.
|
||||
* @retval string
|
||||
* @return string
|
||||
* A string containing formatted headers.
|
||||
* @param array $headers An associative array of header names to header values.
|
||||
*
|
||||
* @return string A string containing formatted headers.
|
||||
*/
|
||||
protected function smashHeaders($headers) {
|
||||
|
||||
|
@ -228,7 +225,7 @@ class PHPStreamTransport implements Transporter {
|
|||
* stream context. This builds the context.
|
||||
*/
|
||||
protected function buildStreamContext($method, $headers, $body) {
|
||||
|
||||
|
||||
// HTTP 1.1 does persistent connections by default where it was opt-in for
|
||||
// HTTP 1.0. In HTTP 1.1 when you want to close a connection you need to
|
||||
// specify a header named Connection with a value of close. We set this as
|
||||
|
@ -274,6 +271,7 @@ class PHPStreamTransport implements Transporter {
|
|||
|
||||
return $context;
|
||||
}
|
||||
|
||||
public function printNotifications($code, $severity, $msg, $msgcode, $bytes, $len) {
|
||||
static $filesize = 'Unknown';
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* A response from a transport.
|
||||
*/
|
||||
namespace OpenStack\Transport;
|
||||
|
@ -57,18 +55,12 @@ class Response {
|
|||
* When a response is a failure, it should pass through this function,
|
||||
* which generates the appropriate exception and then throws it.
|
||||
*
|
||||
* @param int $code
|
||||
* The HTTP status code, e.g. 404, 500.
|
||||
* @param string $err
|
||||
* The error string, as bubbled up.
|
||||
* @param string $uri
|
||||
* The URI.
|
||||
* @param string $method
|
||||
* The HTTP method, e.g. 'HEAD', 'GET', 'DELETE'.
|
||||
* @param string $extra
|
||||
* An extra string of debugging information. (NOT USED)
|
||||
* @throws OpenStack::Exception
|
||||
* A wide variety of OpenStack::Transport exceptions.
|
||||
* @param int $code The HTTP status code, e.g. 404, 500.
|
||||
* @param string $err The error string, as bubbled up.
|
||||
* @param string $uri The URI.
|
||||
* @param string $method The HTTP method, e.g. 'HEAD', 'GET', 'DELETE'.
|
||||
* @param string $extra An extra string of debugging information. (NOT USED)
|
||||
* @throws \OpenStack\Exception A wide variety of \OpenStack\Transport exceptions.
|
||||
*/
|
||||
public static function failure($code, $err = 'Unknown', $uri = '', $method = '', $extra = '') {
|
||||
|
||||
|
@ -135,9 +127,7 @@ class Response {
|
|||
* the handle returned by file() will also be closed
|
||||
* (they are one and the same).
|
||||
*
|
||||
* @retval resource
|
||||
* @return resource
|
||||
* A file handle.
|
||||
* @return resource A file handle.
|
||||
*/
|
||||
public function file() {
|
||||
return $this->handle;
|
||||
|
@ -149,15 +139,12 @@ class Response {
|
|||
* This returns the body of the response (no HTTP headers)
|
||||
* as a single string.
|
||||
*
|
||||
* @attention
|
||||
* IMPORTANT: This can only be called once. HTTP streams
|
||||
* handled by PHP's stream wrapper cannot be rewound, and
|
||||
* to keep memory usage low, we don't want to store the
|
||||
* entire content in a string.
|
||||
*
|
||||
* @retval string
|
||||
* @return string
|
||||
* The contents of the response body.
|
||||
* @return string The contents of the response body.
|
||||
*/
|
||||
public function content() {
|
||||
$out = '';
|
||||
|
@ -197,10 +184,8 @@ class Response {
|
|||
* Some return extra information on the processing of the
|
||||
* data.
|
||||
*
|
||||
* @retval array
|
||||
* @return array
|
||||
* An associative array of metadata about the
|
||||
* transaction resulting in this response.
|
||||
* @return array An associative array of metadata about the transaction
|
||||
* resulting in this response.
|
||||
*/
|
||||
public function metadata() {
|
||||
return $this->metadata;
|
||||
|
@ -209,14 +194,10 @@ class Response {
|
|||
/**
|
||||
* Convenience function to retrieve a single header.
|
||||
*
|
||||
* @param string $name
|
||||
* The name of the header.
|
||||
* @param mixed $default
|
||||
* An optional default value.
|
||||
* @param string $name The name of the header.
|
||||
* @param mixed $default An optional default value.
|
||||
*
|
||||
* @retval mixed
|
||||
* @return mixed
|
||||
* The value, if found, or the default, is specified, or NULL.
|
||||
* @return mixed The value, if found, or the default, is specified, or NULL.
|
||||
*/
|
||||
public function header($name, $default = NULL) {
|
||||
if (isset($this->headers[$name])) {
|
||||
|
@ -234,9 +215,7 @@ class Response {
|
|||
*
|
||||
* These are available even if the stream has been closed.
|
||||
*
|
||||
* @retval array
|
||||
* @return array
|
||||
* The array of headers.
|
||||
* @return array The array of headers.
|
||||
*/
|
||||
public function headers() {
|
||||
return $this->headers;
|
||||
|
@ -263,9 +242,7 @@ class Response {
|
|||
* Redirects are typically followed, and thus rarely (if ever)
|
||||
* appear in a Response object.
|
||||
*
|
||||
* @retval int
|
||||
* @return int
|
||||
* The HTTP code, e.g. 200 or 202.
|
||||
* @return int The HTTP code, e.g. 200 or 202.
|
||||
*/
|
||||
public function status() {
|
||||
return $this->code;
|
||||
|
@ -277,9 +254,7 @@ class Response {
|
|||
* Typically these follow the HTTP protocol specification's
|
||||
* recommendations. e.g. 200 returns 'OK'.
|
||||
*
|
||||
* @retval string
|
||||
* @return string
|
||||
* A server-generated status message.
|
||||
* @return string A server-generated status message.
|
||||
*/
|
||||
public function statusMessage() {
|
||||
return $this->message;
|
||||
|
@ -290,9 +265,7 @@ class Response {
|
|||
*
|
||||
* Example: HTTP/1.1
|
||||
*
|
||||
* @retval string
|
||||
* @return string
|
||||
* The protocol name and version.
|
||||
* @return string The protocol name and version.
|
||||
*/
|
||||
public function protocol() {
|
||||
return $this->protocol;
|
||||
|
@ -305,12 +278,10 @@ class Response {
|
|||
/**
|
||||
* Parse the HTTP headers.
|
||||
*
|
||||
* @param array $headerArray
|
||||
* An indexed array of headers, as returned by the PHP stream
|
||||
* library.
|
||||
* @retval array
|
||||
* @return array
|
||||
* An associative array of header name/value pairs.
|
||||
* @param array $headerArray An indexed array of headers, as returned by the
|
||||
* PHP stream library.
|
||||
*
|
||||
* @return array An associative array of header name/value pairs.
|
||||
*/
|
||||
protected function parseHeaders($headerArray) {
|
||||
$ret = array_shift($headerArray);
|
||||
|
@ -323,7 +294,7 @@ class Response {
|
|||
|
||||
// A CONTINUE response means that we will get
|
||||
// a second HTTP status code. Since we have
|
||||
// shifted it off, we recurse. Note that
|
||||
// shifted it off, we recurse. Note that
|
||||
// only CURL returns the 100. PHP's stream
|
||||
// wrapper eats the 100 for us.
|
||||
if ($this->code == 100) {
|
||||
|
|
|
@ -14,9 +14,7 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
namespace OpenStack\Transport;
|
||||
/**
|
||||
* Represents an HTTP 500 error.
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
* This file contains the interface for transporters.
|
||||
*/
|
||||
|
||||
|
@ -44,14 +43,10 @@ interface Transporter {
|
|||
* transporter. The transporter MUST be capable of handling multiple
|
||||
* invocations of a doRequest() call.
|
||||
*
|
||||
* @param string $uri
|
||||
* The target URI.
|
||||
* @param string $method
|
||||
* The method to be sent.
|
||||
* @param array $headers
|
||||
* An array of name/value header pairs.
|
||||
* @param string $body
|
||||
* The string containing the request body.
|
||||
* @param string $uri The target URI.
|
||||
* @param string $method The method to be sent.
|
||||
* @param array $headers An array of name/value header pairs.
|
||||
* @param string $body The string containing the request body.
|
||||
*/
|
||||
public function doRequest($uri, $method = 'GET', $headers = array(), $body = '');
|
||||
|
||||
|
@ -61,7 +56,7 @@ interface Transporter {
|
|||
*
|
||||
* This is a special version of the doRequest() function.
|
||||
* It handles a very spefic case where...
|
||||
*
|
||||
*
|
||||
* - The HTTP verb requires a body (viz. PUT, POST)
|
||||
* - The body is in a resource, not a string
|
||||
*
|
||||
|
@ -73,17 +68,13 @@ interface Transporter {
|
|||
*
|
||||
* Note that all parameters are required.
|
||||
*
|
||||
* @param string $uri
|
||||
* The target URI.
|
||||
* @param string $method
|
||||
* The method to be sent.
|
||||
* @param array $headers
|
||||
* An array of name/value header pairs.
|
||||
* @param mixed $resource
|
||||
* The string with a file path or a stream URL; or a file object resource.
|
||||
* If it is a string, then it will be opened with the default context.
|
||||
* So if you need a special context, you should open the file elsewhere
|
||||
* and pass the resource in here.
|
||||
* @param string $uri The target URI.
|
||||
* @param string $method The method to be sent.
|
||||
* @param array $headers An array of name/value header pairs.
|
||||
* @param mixed $resource The string with a file path or a stream URL; or a
|
||||
* file object resource. If it is a string, then it will be opened with the
|
||||
* default context. So if you need a special context, you should open the
|
||||
* file elsewhere and pass the resource in here.
|
||||
*/
|
||||
public function doRequestWithResource($uri, $method, $headers, $resource);
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* The authorization exception.
|
||||
*/
|
||||
namespace OpenStack\Transport;
|
||||
|
|
|
@ -14,9 +14,7 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
namespace OpenStack\Transport;
|
||||
/**
|
||||
* Represents an HTTP 422 error.
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
* This is a simple command-line test for authentication.
|
||||
*
|
||||
* You can run the test with `php test/AuthTest.php username key`.
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
* Base test case.
|
||||
*/
|
||||
/**
|
||||
|
@ -104,12 +103,10 @@ class TestCase extends \PHPUnit_Framework_TestCase {
|
|||
* Authentication is performed, and the returned
|
||||
* service has its tenant ID set already.
|
||||
*
|
||||
* @code
|
||||
* <?php
|
||||
* // Get the current token.
|
||||
* $this->identity()->token();
|
||||
* ?>
|
||||
* @endcode
|
||||
* <?php
|
||||
* // Get the current token.
|
||||
* $this->identity()->token();
|
||||
* ?>
|
||||
*/
|
||||
protected function identity($reset = FALSE) {
|
||||
|
||||
|
@ -172,13 +169,12 @@ class TestCase extends \PHPUnit_Framework_TestCase {
|
|||
/**
|
||||
* Clear and destroy a container.
|
||||
*
|
||||
* Destroy all of the files in a container, then destroy the
|
||||
* Destroy all of the files in a container, then destroy the
|
||||
* container.
|
||||
*
|
||||
* If the container doesn't exist, this will silently return.
|
||||
*
|
||||
* @param string $cname
|
||||
* The name of the container.
|
||||
* @param string $cname The name of the container.
|
||||
*/
|
||||
protected function eradicateContainer($cname) {
|
||||
$store = $this->objectStore();
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Unit tests for ObjectStorage ACLs.
|
||||
*/
|
||||
namespace OpenStack\Tests\Storage\ObjectStorage;
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Unit tests for the Autoloader.
|
||||
*/
|
||||
namespace OpenStack\Tests;
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Unit tests for the Bootstrap.
|
||||
*/
|
||||
namespace OpenStack\Tests;
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Unit tests for ObjectStorage Object.
|
||||
*/
|
||||
namespace OpenStack\Tests\Transport;
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Unit tests for Containers.
|
||||
*/
|
||||
namespace OpenStack\Tests\Storage\ObjectStorage;
|
||||
|
@ -71,8 +69,6 @@ class ContainerTest extends \OpenStack\Tests\TestCase {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
const FNAME = 'testSave';
|
||||
const FCONTENT = 'This is a test.';
|
||||
const FTYPE = 'application/x-monkey-file';
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Unit tests for IdentityService.
|
||||
*/
|
||||
namespace OpenStack\Tests\Services;
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Unit tests for ObjectStorage.
|
||||
*/
|
||||
namespace OpenStack\Tests\Storage;
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Unit tests for ObjectStorage Object.
|
||||
*/
|
||||
namespace OpenStack\Tests\Storage;
|
||||
|
@ -37,8 +35,7 @@ class ObjectTest extends \OpenStack\Tests\TestCase {
|
|||
* This provides an Object initialized with the main constants defined
|
||||
* for this class. Use this as a fixture to avoid repetition.
|
||||
*
|
||||
* @return Object
|
||||
* An initialized object.
|
||||
* @return Object An initialized object.
|
||||
*/
|
||||
public function basicObjectFixture() {
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Unit tests for ObjectStorage RemoteObject.
|
||||
*/
|
||||
namespace OpenStack\Tests\Storage\ObjectStorage;
|
||||
|
@ -210,7 +208,7 @@ class RemoteObjectTest extends \OpenStack\Tests\TestCase {
|
|||
|
||||
$this->assertEquals(self::FCONTENT, $content);
|
||||
|
||||
// Finally, we redo the first part of the test to make sure that
|
||||
// Finally, we redo the first part of the test to make sure that
|
||||
// refreshing gets us a new copy:
|
||||
|
||||
$res3 = $obj->stream(TRUE);
|
||||
|
@ -250,7 +248,7 @@ class RemoteObjectTest extends \OpenStack\Tests\TestCase {
|
|||
// remote, and the best way to find this out is by grabbing a
|
||||
// stream. The local copy will be in a php://temp stream.
|
||||
//
|
||||
// The CURL, though, backs its up with a temp file wrapped in a PHP
|
||||
// The CURL, though, backs its up with a temp file wrapped in a PHP
|
||||
// stream. Other backends are likely to do the same. So this test
|
||||
// is weakened for CURL backends.
|
||||
$transport = \OpenStack\Bootstrap::config('transport');
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Unit tests for Response.
|
||||
*/
|
||||
namespace OpenStack\Tests\Transport;
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Unit tests for the stream wrapper file systema.
|
||||
*/
|
||||
namespace OpenStack\Tests\Storage\ObjectStorage;
|
||||
|
@ -60,7 +58,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase {
|
|||
|
||||
// Delete the container and all the contents.
|
||||
$cname = self::$settings['openstack.swift.container'];
|
||||
|
||||
|
||||
try {
|
||||
$container = $store->container($cname);
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Unit tests for the stream wrapper.
|
||||
*/
|
||||
namespace OpenStack\Tests\Storage\ObjectStorage;
|
||||
|
@ -57,7 +55,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase {
|
|||
|
||||
// Delete the container and all the contents.
|
||||
$cname = self::$settings['openstack.swift.container'];
|
||||
|
||||
|
||||
try {
|
||||
$container = $store->container($cname);
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Helpers for testing using the CurlTransport.
|
||||
*/
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
limitations under the License.
|
||||
============================================================================ */
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Helpers for testing using the CurlTransport.
|
||||
*/
|
||||
|
||||
|
|
Loading…
Reference in New Issue