Skip to content

Commit

Permalink
Added CDN SSL URI stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Conrad Weidenkeller committed Mar 9, 2011
1 parent 76dff8b commit 080cab9
Show file tree
Hide file tree
Showing 15 changed files with 190 additions and 77 deletions.
3 changes: 3 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1.7.8 Conrad Weidenkeller <[email protected]>
* Added CDN SSL URI Stuff

1.7.7 Conrad Weidenkeller <[email protected]>
* Added CDN Purge Functionality

Expand Down
37 changes: 34 additions & 3 deletions cloudfiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,7 @@ class CF_Container
public $bytes_used;

public $cdn_enabled;
public $cdn_ssl_uri;
public $cdn_uri;
public $cdn_ttl;
public $cdn_log_retention;
Expand Down Expand Up @@ -959,6 +960,7 @@ function __construct(&$cfs_auth, &$cfs_http, $name, $count=0,
$this->bytes_used = $bytes;
$this->cdn_enabled = NULL;
$this->cdn_uri = NULL;
$this->cdn_ssl_uri = NULL;
$this->cdn_ttl = NULL;
$this->cdn_log_retention = NULL;
$this->cdn_acl_user_agent = NULL;
Expand Down Expand Up @@ -1044,13 +1046,13 @@ function make_public($ttl=86400)
if ($status == 404) {
# this instance _thinks_ the container was published, but the
# cdn management system thinks otherwise - try again with a PUT
list($status, $reason, $cdn_uri) =
list($status, $reason, $cdn_uri, $cdn_ssl_uri) =
$this->cfs_http->add_cdn_container($this->name,$ttl);

}
} else {
# publish it for first time
list($status, $reason, $cdn_uri) =
list($status, $reason, $cdn_uri, $cdn_ssl_uri) =
$this->cfs_http->add_cdn_container($this->name,$ttl);
}
#if ($status == 401 && $this->_re_auth()) {
Expand All @@ -1062,6 +1064,7 @@ function make_public($ttl=86400)
}
$this->cdn_enabled = True;
$this->cdn_ttl = $ttl;
$this->cdn_ssl_uri = $cdn_ssl_uri;
$this->cdn_uri = $cdn_uri;
$this->cdn_log_retention = False;
$this->cdn_acl_user_agent = "";
Expand Down Expand Up @@ -1272,6 +1275,7 @@ function make_private()
$this->cdn_enabled = False;
$this->cdn_ttl = NULL;
$this->cdn_uri = NULL;
$this->cdn_ssl_uri = NULL;
$this->cdn_log_retention = NULL;
$this->cdn_acl_user_agent = NULL;
$this->cdn_acl_referrer = NULL;
Expand Down Expand Up @@ -1579,7 +1583,7 @@ function create_paths($path_name)
*/
private function _cdn_initialize()
{
list($status, $reason, $cdn_enabled, $cdn_uri, $cdn_ttl,
list($status, $reason, $cdn_enabled, $cdn_ssl_uri, $cdn_uri, $cdn_ttl,
$cdn_log_retention, $cdn_acl_user_agent, $cdn_acl_referrer) =
$this->cfs_http->head_cdn_container($this->name);
#if ($status == 401 && $this->_re_auth()) {
Expand All @@ -1590,6 +1594,7 @@ private function _cdn_initialize()
"Invalid response (".$status."): ".$this->cfs_http->get_error());
}
$this->cdn_enabled = $cdn_enabled;
$this->cdn_ssl_uri = $cdn_ssl_uri;
$this->cdn_uri = $cdn_uri;
$this->cdn_ttl = $cdn_ttl;
$this->cdn_log_retention = $cdn_log_retention;
Expand Down Expand Up @@ -1768,6 +1773,32 @@ function public_uri()
return NULL;
}

/**
* String representation of the Object's public SSL URI
*
* A string representing the Object's public SSL URI assuming that it's
* parent Container is CDN-enabled.
*
* Example:
* <code>
* # ... authentication/connection/container code excluded
* # ... see previous examples
*
* # Print out the Object's CDN SSL URI (if it has one) in an HTML img-tag
* #
* print "<img src='$pic->public_ssl_uri()' />\n";
* </code>
*
* @return string Object's public SSL URI or NULL
*/
function public_ssl_uri()
{
if ($this->container->cdn_enabled) {
return $this->container->cdn_ssl_uri . "/" . $this->name;
}
return NULL;
}

/**
* Read the remote Object's data
*
Expand Down
16 changes: 13 additions & 3 deletions cloudfiles_http.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
*/
require_once("cloudfiles_exceptions.php");

define("PHP_CF_VERSION", "1.7.7");
define("PHP_CF_VERSION", "1.7.8");
define("USER_AGENT", sprintf("PHP-CloudFiles/%s", PHP_CF_VERSION));
define("ACCOUNT_CONTAINER_COUNT", "X-Account-Container-Count");
define("ACCOUNT_BYTES_USED", "X-Account-Bytes-Used");
define("CONTAINER_OBJ_COUNT", "X-Container-Object-Count");
define("CONTAINER_BYTES_USED", "X-Container-Bytes-Used");
define("METADATA_HEADER", "X-Object-Meta-");
define("CDN_URI", "X-CDN-URI");
define("CDN_SSL_URI", "X-CDN-SSL-URI");
define("CDN_ENABLED", "X-CDN-Enabled");
define("CDN_LOG_RETENTION", "X-Log-Retention");
define("CDN_ACL_USER_AGENT", "X-User-Agent-ACL");
Expand Down Expand Up @@ -96,6 +97,7 @@ class CF_Http
private $_obj_write_resource;
private $_obj_write_string;
private $_cdn_enabled;
private $_cdn_ssl_uri;
private $_cdn_uri;
private $_cdn_ttl;
private $_cdn_log_retention;
Expand Down Expand Up @@ -146,6 +148,7 @@ function __construct($api_version)
$this->_obj_content_length = NULL;
$this->_obj_metadata = array();
$this->_cdn_enabled = NULL;
$this->_cdn_ssl_uri = NULL;
$this->_cdn_uri = NULL;
$this->_cdn_ttl = NULL;
$this->_cdn_log_retention = NULL;
Expand Down Expand Up @@ -338,7 +341,8 @@ function add_cdn_container($container_name, $ttl=86400)
$this->error_str="Unexpected HTTP response: ".$this->response_reason;
return array($return_code,$this->response_reason,False);
}
return array($return_code,$this->response_reason,$this->_cdn_uri);
return array($return_code,$this->response_reason,$this->_cdn_uri,
$this->_cdn_ssl_uri);
}

# (CDN) POST /v1/Account/Container
Expand Down Expand Up @@ -395,7 +399,8 @@ function head_cdn_container($container_name)
}
if ($return_code == 204) {
return array($return_code,$this->response_reason,
$this->_cdn_enabled, $this->_cdn_uri, $this->_cdn_ttl,
$this->_cdn_enabled, $this->_cdn_ssl_uri,
$this->_cdn_uri, $this->_cdn_ttl,
$this->_cdn_log_retention,
$this->_cdn_acl_user_agent,
$this->_cdn_acl_referrer
Expand Down Expand Up @@ -1011,6 +1016,10 @@ private function _header_cb($ch, $header)
$this->_cdn_uri = trim(substr($header, strlen(CDN_URI)+1));
return strlen($header);
}
if (stripos($header, CDN_SSL_URI) === 0) {
$this->_cdn_ssl_uri = trim(substr($header, strlen(CDN_SSL_URI)+1));
return strlen($header);
}
if (stripos($header, CDN_TTL) === 0) {
$this->_cdn_ttl = trim(substr($header, strlen(CDN_TTL)+1))+0;
return strlen($header);
Expand Down Expand Up @@ -1245,6 +1254,7 @@ private function _reset_callback_vars()
$this->_obj_metadata = array();
$this->_obj_write_string = "";
$this->_cdn_enabled = NULL;
$this->_cdn_ssl_uri = NULL;
$this->_cdn_uri = NULL;
$this->_cdn_ttl = NULL;
$this->response_status = 0;
Expand Down
4 changes: 2 additions & 2 deletions docs/classtrees_php-cloudfiles.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
<td width="200" class="menu">
<div id="ric">
<p><a href="ric_AUTHORS.html">AUTHORS</a></p>
<p><a href="ric_COPYING.html">COPYING</a></p>
<p><a href="ric_README.html">README</a></p>
<p><a href="ric_COPYING.html">COPYING</a></p>
<p><a href="ric_Changelog.html">Changelog</a></p>
</div>
<b>Packages:</b><br />
Expand Down Expand Up @@ -63,7 +63,7 @@ <h1>Class Trees for Package php-cloudfiles</h1>

<div class="credit">
<hr />
Documentation generated on Thu, 24 Feb 2011 15:05:56 -0600 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Wed, 09 Mar 2011 13:07:29 +0000 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>
Expand Down
16 changes: 11 additions & 5 deletions docs/elementindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
<td width="200" class="menu">
<div id="ric">
<p><a href="ric_AUTHORS.html">AUTHORS</a></p>
<p><a href="ric_COPYING.html">COPYING</a></p>
<p><a href="ric_README.html">README</a></p>
<p><a href="ric_COPYING.html">COPYING</a></p>
<p><a href="ric_Changelog.html">Changelog</a></p>
</div>
<b>Packages:</b><br />
<a href="li_php-cloudfiles.html">php-cloudfiles</a><br />
<a href="li_php-cloudfiles-exceptions.html">php-cloudfiles-exceptions</a><br />
<a href="li_php-cloudfiles-http.html">php-cloudfiles-http</a><br />
<a href="li_php-cloudfiles.html">php-cloudfiles</a><br />
<br /><br />
</td>
<td>
Expand Down Expand Up @@ -131,6 +131,8 @@ <h2>c</h2>
<dd>in file cloudfiles.php, variable <a href="php-cloudfiles/CF_Container.html#var$cdn_enabled">CF_Container::$cdn_enabled</a></dd>
<dt><b>$cdn_log_retention</b></dt>
<dd>in file cloudfiles.php, variable <a href="php-cloudfiles/CF_Container.html#var$cdn_log_retention">CF_Container::$cdn_log_retention</a></dd>
<dt><b>$cdn_ssl_uri</b></dt>
<dd>in file cloudfiles.php, variable <a href="php-cloudfiles/CF_Container.html#var$cdn_ssl_uri">CF_Container::$cdn_ssl_uri</a></dd>
<dt><b>$cdn_ttl</b></dt>
<dd>in file cloudfiles.php, variable <a href="php-cloudfiles/CF_Container.html#var$cdn_ttl">CF_Container::$cdn_ttl</a></dd>
<dt><b>$cdn_uri</b></dt>
Expand Down Expand Up @@ -163,6 +165,8 @@ <h2>c</h2>
<dd>in file cloudfiles_http.php, constant <a href="php-cloudfiles-http/_cloudfiles_http.php.html#defineCDN_ENABLED">CDN_ENABLED</a></dd>
<dt><b>CDN_LOG_RETENTION</b></dt>
<dd>in file cloudfiles_http.php, constant <a href="php-cloudfiles-http/_cloudfiles_http.php.html#defineCDN_LOG_RETENTION">CDN_LOG_RETENTION</a></dd>
<dt><b>CDN_SSL_URI</b></dt>
<dd>in file cloudfiles_http.php, constant <a href="php-cloudfiles-http/_cloudfiles_http.php.html#defineCDN_SSL_URI">CDN_SSL_URI</a></dd>
<dt><b>CDN_TTL</b></dt>
<dd>in file cloudfiles_http.php, constant <a href="php-cloudfiles-http/_cloudfiles_http.php.html#defineCDN_TTL">CDN_TTL</a></dd>
<dt><b>CDN_URI</b></dt>
Expand All @@ -178,9 +182,9 @@ <h2>c</h2>
<dt><b>CF_Object</b></dt>
<dd>in file cloudfiles.php, class <a href="php-cloudfiles/CF_Object.html">CF_Object</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Object operations</dd>
<dt><b>close</b></dt>
<dd>in file cloudfiles.php, method <a href="php-cloudfiles/CF_Connection.html#methodclose">CF_Connection::close()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Close a connection</dd>
<dt><b>close</b></dt>
<dd>in file cloudfiles_http.php, method <a href="php-cloudfiles-http/CF_Http.html#methodclose">CF_Http::close()</a></dd>
<dt><b>close</b></dt>
<dd>in file cloudfiles.php, method <a href="php-cloudfiles/CF_Connection.html#methodclose">CF_Connection::close()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Close a connection</dd>
<dt><b>cloudfiles.php</b></dt>
<dd>procedural page <a href="php-cloudfiles/_cloudfiles.php.html">cloudfiles.php</a></dd>
<dt><b>cloudfiles_exceptions.php</b></dt>
Expand Down Expand Up @@ -397,6 +401,8 @@ <h2>p</h2>
<dl>
<dt><b>PHP_CF_VERSION</b></dt>
<dd>in file cloudfiles_http.php, constant <a href="php-cloudfiles-http/_cloudfiles_http.php.html#definePHP_CF_VERSION">PHP_CF_VERSION</a></dd>
<dt><b>public_ssl_uri</b></dt>
<dd>in file cloudfiles.php, method <a href="php-cloudfiles/CF_Object.html#methodpublic_ssl_uri">CF_Object::public_ssl_uri()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;String representation of the Object's public SSL URI</dd>
<dt><b>public_uri</b></dt>
<dd>in file cloudfiles.php, method <a href="php-cloudfiles/CF_Object.html#methodpublic_uri">CF_Object::public_uri()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;String representation of the Object's public URI</dd>
<dt><b>purge_from_cdn</b></dt>
Expand Down Expand Up @@ -522,7 +528,7 @@ <h2>_</h2>
<a href="elementindex.html#top">top</a><br>
<div class="credit">
<hr />
Documentation generated on Thu, 24 Feb 2011 15:05:56 -0600 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Wed, 09 Mar 2011 13:07:29 +0000 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>
Expand Down
14 changes: 9 additions & 5 deletions docs/elementindex_php-cloudfiles.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<tr>
<td class="header_menu">

[ <a href="classtrees_php-cloudfiles.html" class="menu">class tree: php-cloudfiles</a> ]

[ <a href="classtrees_php-cloudfiles.html" class="menu">class tree: php-cloudfiles</a> ]
[ <a href="elementindex_php-cloudfiles.html" class="menu">index: php-cloudfiles</a> ]
[ <a href="elementindex.html" class="menu">all elements</a> ]
</td>
Expand All @@ -27,14 +27,14 @@
<td width="200" class="menu">
<div id="ric">
<p><a href="ric_AUTHORS.html">AUTHORS</a></p>
<p><a href="ric_COPYING.html">COPYING</a></p>
<p><a href="ric_README.html">README</a></p>
<p><a href="ric_COPYING.html">COPYING</a></p>
<p><a href="ric_Changelog.html">Changelog</a></p>
</div>
<b>Packages:</b><br />
<a href="li_php-cloudfiles.html">php-cloudfiles</a><br />
<a href="li_php-cloudfiles-exceptions.html">php-cloudfiles-exceptions</a><br />
<a href="li_php-cloudfiles-http.html">php-cloudfiles-http</a><br />
<a href="li_php-cloudfiles.html">php-cloudfiles</a><br />
<br /><br />
<b>Files:</b><br />
<div class="package">
Expand Down Expand Up @@ -145,6 +145,8 @@ <h2>c</h2>
<dd>in file cloudfiles.php, variable <a href="php-cloudfiles/CF_Container.html#var$cdn_enabled">CF_Container::$cdn_enabled</a></dd>
<dt><b>$cdn_log_retention</b></dt>
<dd>in file cloudfiles.php, variable <a href="php-cloudfiles/CF_Container.html#var$cdn_log_retention">CF_Container::$cdn_log_retention</a></dd>
<dt><b>$cdn_ssl_uri</b></dt>
<dd>in file cloudfiles.php, variable <a href="php-cloudfiles/CF_Container.html#var$cdn_ssl_uri">CF_Container::$cdn_ssl_uri</a></dd>
<dt><b>$cdn_ttl</b></dt>
<dd>in file cloudfiles.php, variable <a href="php-cloudfiles/CF_Container.html#var$cdn_ttl">CF_Container::$cdn_ttl</a></dd>
<dt><b>$cdn_uri</b></dt>
Expand Down Expand Up @@ -315,6 +317,8 @@ <h2>o</h2>
<div>
<h2>p</h2>
<dl>
<dt><b>public_ssl_uri</b></dt>
<dd>in file cloudfiles.php, method <a href="php-cloudfiles/CF_Object.html#methodpublic_ssl_uri">CF_Object::public_ssl_uri()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;String representation of the Object's public SSL URI</dd>
<dt><b>public_uri</b></dt>
<dd>in file cloudfiles.php, method <a href="php-cloudfiles/CF_Object.html#methodpublic_uri">CF_Object::public_uri()</a><br>&nbsp;&nbsp;&nbsp;&nbsp;String representation of the Object's public URI</dd>
<dt><b>purge_from_cdn</b></dt>
Expand Down Expand Up @@ -390,7 +394,7 @@ <h2>w</h2>
<a href="elementindex_php-cloudfiles.html#top">top</a><br>
<div class="credit">
<hr />
Documentation generated on Thu, 24 Feb 2011 15:05:56 -0600 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Wed, 09 Mar 2011 13:07:29 +0000 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>
Expand Down
8 changes: 4 additions & 4 deletions docs/errors.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
<td width="200" class="menu">
<div id="ric">
<p><a href="ric_AUTHORS.html">AUTHORS</a></p>
<p><a href="ric_COPYING.html">COPYING</a></p>
<p><a href="ric_README.html">README</a></p>
<p><a href="ric_COPYING.html">COPYING</a></p>
<p><a href="ric_Changelog.html">Changelog</a></p>
</div>
<b>Packages:</b><br />
Expand Down Expand Up @@ -60,11 +60,11 @@ <h2>Warnings:</h2><br>
<a name="cloudfiles.php"></a>
<h1>cloudfiles.php</h1>
<h2>Errors:</h2><br>
<b>Error on line 1087</b> - Unclosed code tag in DocBlock, parsing will be incorrect<br>
<b>Error on line 2115</b> - Unclosed code tag in DocBlock, parsing will be incorrect<br>
<b>Error on line 1090</b> - Unclosed code tag in DocBlock, parsing will be incorrect<br>
<b>Error on line 2146</b> - Unclosed code tag in DocBlock, parsing will be incorrect<br>
<div class="credit">
<hr />
Documentation generated on Thu, 24 Feb 2011 15:05:57 -0600 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Wed, 09 Mar 2011 13:07:31 +0000 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>
Expand Down
4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
<td width="200" class="menu">
<div id="ric">
<p><a href="ric_AUTHORS.html">AUTHORS</a></p>
<p><a href="ric_COPYING.html">COPYING</a></p>
<p><a href="ric_README.html">README</a></p>
<p><a href="ric_COPYING.html">COPYING</a></p>
<p><a href="ric_Changelog.html">Changelog</a></p>
</div>
<b>Packages:</b><br />
Expand Down Expand Up @@ -60,7 +60,7 @@
This documentation was generated by <a href="http://www.phpdoc.org">phpDocumentor v1.4.3</a><br />
<div class="credit">
<hr />
Documentation generated on Thu, 24 Feb 2011 15:05:56 -0600 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Wed, 09 Mar 2011 13:07:29 +0000 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>
Expand Down
4 changes: 2 additions & 2 deletions docs/li_php-cloudfiles.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
<td width="200" class="menu">
<div id="ric">
<p><a href="ric_AUTHORS.html">AUTHORS</a></p>
<p><a href="ric_COPYING.html">COPYING</a></p>
<p><a href="ric_README.html">README</a></p>
<p><a href="ric_COPYING.html">COPYING</a></p>
<p><a href="ric_Changelog.html">Changelog</a></p>
</div>
<b>Packages:</b><br />
Expand Down Expand Up @@ -60,7 +60,7 @@
This documentation was generated by <a href="http://www.phpdoc.org">phpDocumentor v1.4.3</a><br />
<div class="credit">
<hr />
Documentation generated on Thu, 24 Feb 2011 15:05:56 -0600 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Wed, 09 Mar 2011 13:07:29 +0000 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>
Expand Down
4 changes: 2 additions & 2 deletions docs/php-cloudfiles/CF_Authentication.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
<td width="200" class="menu">
<div id="ric">
<p><a href="../ric_AUTHORS.html">AUTHORS</a></p>
<p><a href="../ric_COPYING.html">COPYING</a></p>
<p><a href="../ric_README.html">README</a></p>
<p><a href="../ric_COPYING.html">COPYING</a></p>
<p><a href="../ric_Changelog.html">Changelog</a></p>
</div>
<b>Packages:</b><br />
Expand Down Expand Up @@ -608,7 +608,7 @@ <h4>Parameters:</h4>

<div class="credit">
<hr />
Documentation generated on Thu, 24 Feb 2011 15:05:56 -0600 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
Documentation generated on Wed, 09 Mar 2011 13:07:30 +0000 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
</div>
</td></tr></table>
</td>
Expand Down
Loading

0 comments on commit 080cab9

Please sign in to comment.