summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2020-06-22 11:43:12 +0200
committerErich Eckner <git@eckner.net>2020-06-22 11:43:12 +0200
commit045444dee303d60e74edd8efa28ebc0fbd7907d1 (patch)
treec6d6ba6a6cfc1dba21571aafab0d0988da5d3ae7
parent521a03a54080c4a1915ce672107f93cf0177eab4 (diff)
downloadsourceMirror-045444dee303d60e74edd8efa28ebc0fbd7907d1.tar.xz
mirror.php: give estimate of size in Header
-rw-r--r--mirror.php9
1 files changed, 9 insertions, 0 deletions
diff --git a/mirror.php b/mirror.php
index 8701035..0cc2836 100644
--- a/mirror.php
+++ b/mirror.php
@@ -74,6 +74,14 @@
}
}
if (! file_exists($pfad)) {
+ $size = shell_exec(
+ "curl -ILs -A 'Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0' '".$quelle."' " .
+ "| sed '" .
+ "s/^Content-Length: //;t;d" .
+ "'"
+ );
+ if (! empty($size))
+ header('Content-Length: ' . $size);
passthru(
"mkdir -p '".dirname($pfad)."'; ".
"( ".
@@ -85,6 +93,7 @@
);
}
else {
+ header('Content-Length: ' . $stat['size']);
$handle = fopen($pfad);
fpassthru($handle);
fclose($handle);