Gracefully handle lack of the cookie
This commit is contained in:
		@@ -122,7 +122,7 @@ function uupFetchUpd(
 | 
				
			|||||||
    consoleLogger('Fetching information from the server...');
 | 
					    consoleLogger('Fetching information from the server...');
 | 
				
			||||||
    $composerArgs = [$arch, $flight, $ring, $build, $sku, $type, $flags];
 | 
					    $composerArgs = [$arch, $flight, $ring, $build, $sku, $type, $flags];
 | 
				
			||||||
    $out = sendWuPostRequestHelper('client', 'composeFetchUpdRequest', $composerArgs);
 | 
					    $out = sendWuPostRequestHelper('client', 'composeFetchUpdRequest', $composerArgs);
 | 
				
			||||||
    if($out['error'] != 200) {
 | 
					    if($out === false || $out['error'] != 200) {
 | 
				
			||||||
        consoleLogger('The request has failed');
 | 
					        consoleLogger('The request has failed');
 | 
				
			||||||
        return array('error' => 'WU_REQUEST_FAILED');
 | 
					        return array('error' => 'WU_REQUEST_FAILED');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								get.php
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								get.php
									
									
									
									
									
								
							@@ -399,7 +399,7 @@ function uupGetOnlineFiles($updateId, $rev, $info, $cacheRequests, $type) {
 | 
				
			|||||||
        $composerArgs = [$updateId, $info, $rev, $type];
 | 
					        $composerArgs = [$updateId, $info, $rev, $type];
 | 
				
			||||||
        $out = sendWuPostRequestHelper('clientSecured', 'composeFileGetRequest', $composerArgs);
 | 
					        $out = sendWuPostRequestHelper('clientSecured', 'composeFileGetRequest', $composerArgs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if($out['error'] != 200) {
 | 
					        if($out === false || $out['error'] != 200) {
 | 
				
			||||||
            consoleLogger('The request has failed');
 | 
					            consoleLogger('The request has failed');
 | 
				
			||||||
            return array('error' => 'WU_REQUEST_FAILED');
 | 
					            return array('error' => 'WU_REQUEST_FAILED');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,6 +60,9 @@ function uupEncryptedData() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    if(empty($cookieInfo)) {
 | 
					    if(empty($cookieInfo)) {
 | 
				
			||||||
        $data = sendWuPostRequestHelper('client', 'composeGetCookieRequest', [], false);
 | 
					        $data = sendWuPostRequestHelper('client', 'composeGetCookieRequest', [], false);
 | 
				
			||||||
 | 
					        if($data === false || $data['error'] != 200) 
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $cookieInfo = uupSaveCookieFromResponse($data['out']);
 | 
					        $cookieInfo = uupSaveCookieFromResponse($data['out']);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,7 +16,7 @@ limitations under the License.
 | 
				
			|||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function uupApiVersion() {
 | 
					function uupApiVersion() {
 | 
				
			||||||
    return '1.43.1';
 | 
					    return '1.43.2';
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
require_once dirname(__FILE__).'/auths.php';
 | 
					require_once dirname(__FILE__).'/auths.php';
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -362,8 +362,11 @@ XML;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Composes POST data for fetching the latest update information from Windows Update
 | 
					// Composes POST data for fetching the latest update information from Windows Update
 | 
				
			||||||
function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type = 'Production', $flags = []) {
 | 
					function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type = 'Production', $flags = []) {
 | 
				
			||||||
    $device = uupDevice();
 | 
					 | 
				
			||||||
    $encData = uupEncryptedData();
 | 
					    $encData = uupEncryptedData();
 | 
				
			||||||
 | 
					    if($encData === false)
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    $device = uupDevice();
 | 
				
			||||||
    $uuid = genUUID();
 | 
					    $uuid = genUUID();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $createdTime = time();
 | 
					    $createdTime = time();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -102,6 +102,9 @@ function sendWuPostRequestHelper(
 | 
				
			|||||||
    ];
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $postData = call_user_func_array($postComposer, $postComposerArgs);
 | 
					    $postData = call_user_func_array($postComposer, $postComposerArgs);
 | 
				
			||||||
 | 
					    if($postData === false)
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $data = sendWuPostRequestInternal($endpoints[$endpoint], $postData, $saveCookie);
 | 
					    $data = sendWuPostRequestInternal($endpoints[$endpoint], $postData, $saveCookie);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if($data['error'] == 500 && preg_match('/<ErrorCode>(ConfigChanged|CookieExpired|InvalidCookie)<\/ErrorCode>/', $data['out'])) {
 | 
					    if($data['error'] == 500 && preg_match('/<ErrorCode>(ConfigChanged|CookieExpired|InvalidCookie)<\/ErrorCode>/', $data['out'])) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user