Browse Source

Merge pull request #1821 from jonchen727/v2-develop

change HTTP protocol to 1.1 for image caching function
causefx 4 years ago
parent
commit
29c91bb53e
1 changed files with 8 additions and 1 deletions
  1. 8 1
      api/functions/organizr-functions.php

+ 8 - 1
api/functions/organizr-functions.php

@@ -543,8 +543,15 @@ trait OrganizrFunctions
 		}
 		$cacheFile = $cacheDirectory . $name . '.' . $extension;
 		$cacheTime = 604800;
+		$ctx = stream_context_create(array(
+			'http' => array(
+				'timeout' =>5 ,
+				'protocol_version' => 1.1,
+				'header' => 'Connection: close'
+			)
+			));
 		if ((file_exists($cacheFile) && (time() - $cacheTime) > filemtime($cacheFile)) || !file_exists($cacheFile)) {
-			@copy($url, $cacheFile);
+			@copy($url, $cacheFile, $ctx);
 		}
 	}