r109235 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109234‎ | r109235 | r109236 >
Date:22:44, 17 January 2012
Author:aaron
Status:ok
Tags:filebackend 
Comment:
Support custom headers for HEAD operations, e.g. ("X-Newest: true"); read() and stream() already allow such headers.
Modified paths:
  • /trunk/extensions/SwiftCloudFiles/php-cloudfiles-1.7.10/cloudfiles.php (modified) (history)
  • /trunk/extensions/SwiftCloudFiles/php-cloudfiles-1.7.10/cloudfiles_http.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SwiftCloudFiles/php-cloudfiles-1.7.10/cloudfiles.php
@@ -1332,11 +1332,12 @@
13331333 * </code>
13341334 *
13351335 * @param string $obj_name name of storage Object
 1336+ * @param array $hdrs user-defined headers (X-Newest: true, etc.)
13361337 * @return obj CF_Object instance
13371338 */
1338 - function create_object($obj_name=NULL)
 1339+ function create_object($obj_name=NULL, $hdrs=array())
13391340 {
1340 - return new CF_Object($this, $obj_name);
 1341+ return new CF_Object($this, $obj_name, False, True, $hdrs);
13411342 }
13421343
13431344 /**
@@ -1361,11 +1362,12 @@
13621363 * </code>
13631364 *
13641365 * @param string $obj_name name of storage Object
 1366+ * @param array $hdrs user-defined headers (X-Newest: true, etc.)
13651367 * @return obj CF_Object instance
13661368 */
1367 - function get_object($obj_name=NULL)
 1369+ function get_object($obj_name=NULL, $hdrs=array())
13681370 {
1369 - return new CF_Object($this, $obj_name, True);
 1371+ return new CF_Object($this, $obj_name, True, True, $hdrs);
13701372 }
13711373
13721374 /**
@@ -1898,8 +1900,10 @@
18991901 * @param obj $container CF_Container instance
19001902 * @param string $name name of Object
19011903 * @param boolean $force_exists if set, throw an error if Object doesn't exist
 1904+ * @param boolean $dohead if set, do a HEAD request to get object metadata
 1905+ * @param array $hdrs user-defined headers (X-Newest: true, etc.)
19021906 */
1903 - function __construct(&$container, $name, $force_exists=False, $dohead=True)
 1907+ function __construct(&$container, $name, $force_exists=False, $dohead=True, $hdrs=array())
19041908 {
19051909 if ($name[0] == "/") {
19061910 $r = "Object name '".$name;
@@ -1921,7 +1925,7 @@
19221926 $this->headers = array();
19231927 $this->manifest = NULL;
19241928 if ($dohead) {
1925 - if (!$this->_initialize() && $force_exists) {
 1929+ if (!$this->_initialize($hdrs) && $force_exists) {
19261930 throw new NoSuchObjectException("No such object '".$name."'");
19271931 }
19281932 }
@@ -2541,11 +2545,11 @@
25422546 /**
25432547 * PRIVATE: fetch information about the remote Object if it exists
25442548 */
2545 - private function _initialize()
 2549+ private function _initialize($hdrs=array())
25462550 {
25472551 list($status, $reason, $etag, $last_modified, $content_type,
25482552 $content_length, $metadata, $manifest, $headers) =
2549 - $this->container->cfs_http->head_object($this);
 2553+ $this->container->cfs_http->head_object($this,$hdrs);
25502554 #if ($status == 401 && $this->_re_auth()) {
25512555 # return $this->_initialize();
25522556 #}
Index: trunk/extensions/SwiftCloudFiles/php-cloudfiles-1.7.10/cloudfiles_http.php
@@ -903,7 +903,7 @@
904904
905905 # HEAD /v1/Account/Container/Object
906906 #
907 - function head_object(&$obj)
 907+ function head_object(&$obj, $hdrs=array())
908908 {
909909 if (!is_object($obj) || get_class($obj) != "CF_Object") {
910910 throw new SyntaxException(
@@ -913,7 +913,7 @@
914914 $conn_type = "HEAD";
915915
916916 $url_path = $this->_make_path("STORAGE", $obj->container->name,$obj->name);
917 - $return_code = $this->_send_request($conn_type,$url_path);
 917+ $return_code = $this->_send_request($conn_type,$url_path,$hdrs);
918918
919919 if (!$return_code) {
920920 $this->error_str .= ": Failed to obtain valid HTTP response.";

Follow-up revisions

RevisionCommit summaryAuthorDate
r109428In SwiftFileBackend:...aaron19:57, 18 January 2012

Status & tagging log