diff --git a/php/src/file/csv/CsvBuilder.php b/php/src/file/csv/CsvBuilder.php index 24899b9..ef30d2c 100644 --- a/php/src/file/csv/CsvBuilder.php +++ b/php/src/file/csv/CsvBuilder.php @@ -26,7 +26,7 @@ class CsvBuilder extends AbstractBuilder { } protected function _checkOk(): bool { - $size = $this->ftell(); + $this->size = $size = $this->ftell(); if ($size === 0) return false; $this->rewind(); return true; diff --git a/php/src/file/tab/AbstractBuilder.php b/php/src/file/tab/AbstractBuilder.php index 45c1cd9..4514442 100644 --- a/php/src/file/tab/AbstractBuilder.php +++ b/php/src/file/tab/AbstractBuilder.php @@ -131,6 +131,8 @@ abstract class AbstractBuilder extends TempStream implements IBuilder { protected bool $built = false, $closed = false; + protected ?int $size = null; + function build(?iterable $rows=null, bool $close=true): bool { $ok = true; if (!$this->built) { @@ -155,6 +157,10 @@ abstract class AbstractBuilder extends TempStream implements IBuilder { if ($output !== null) { http::download_as(path::filename($output)); } + $size = $this->size; + if ($size !== null) { + header("Content-Length: $size"); + } $this->sentHeaders = true; }