support content-length
This commit is contained in:
parent
ce337ce3bc
commit
5dc2d3d019
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user