Require only one of ETag and Last-Modified in 2.1 package servers
authorTim Düsterhus <duesterhus@woltlab.com>
Sat, 3 Jan 2015 23:10:10 +0000 (00:10 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Sat, 3 Jan 2015 23:10:10 +0000 (00:10 +0100)
wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php

index 55ca9971c2c7c3b8d7592da2de2085375692a883..6bd7174613b59be0654dfe50b623d81c7d90c146 100644 (file)
@@ -91,10 +91,8 @@ class PackageUpdateDispatcher extends SingletonFactory {
                
                if ($updateServer->apiVersion == '2.1') {
                        $metaData = $updateServer->getMetaData();
-                       if (!empty($metaData['list'])) {
-                               $request->addHeader('if-none-match', $metaData['list']['etag']);
-                               $request->addHeader('if-modified-since', $metaData['list']['lastModified']);
-                       }
+                       if (isset($metaData['list']['etag'])) $request->addHeader('if-none-match', $metaData['list']['etag']);
+                       if (isset($metaData['list']['lastModified'])) $request->addHeader('if-modified-since', $metaData['list']['lastModified']);
                }
                
                try {
@@ -133,17 +131,17 @@ class PackageUpdateDispatcher extends SingletonFactory {
                
                $metaData = array();
                if ($updateServer->apiVersion == '2.1' || (isset($data['apiVersion']) && $data['apiVersion'] == '2.1')) {
-                       if (empty($reply['httpHeaders']['etag']) || empty($reply['httpHeaders']['last-modified'])) {
-                               throw new SystemException("Missing required HTTP headers 'etag' and/or 'last-modified'.");
+                       if (empty($reply['httpHeaders']['etag']) && empty($reply['httpHeaders']['last-modified'])) {
+                               throw new SystemException("Missing required HTTP headers 'etag' and 'last-modified'.");
                        }
                        else if (empty($reply['httpHeaders']['wcf-update-server-ssl'])) {
                                throw new SystemException("Missing required HTTP header 'wcf-update-server-ssl'.");
                        }
                        
-                       $metaData['list'] = array(
-                               'etag' => reset($reply['httpHeaders']['etag']),
-                               'lastModified' => reset($reply['httpHeaders']['last-modified'])
-                       );
+                       $metaData['list'] = array();
+                       if (!empty($reply['httpHeaders']['etag'])) $metaData['list']['etag'] = reset($reply['httpHeaders']['etag']);
+                       if (!empty($reply['httpHeaders']['last-modified'])) $metaData['list']['lastModified'] = reset($reply['httpHeaders']['last-modified']);
+                       
                        $metaData['ssl'] = (reset($reply['httpHeaders']['wcf-update-server-ssl']) == 'true') ? true : false;
                }
                $data['metaData'] = serialize($metaData);