support content-length
This commit is contained in:
parent
ce337ce3bc
commit
5dc2d3d019
@ -26,7 +26,7 @@ class CsvBuilder extends AbstractBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function _checkOk(): bool {
|
protected function _checkOk(): bool {
|
||||||
$size = $this->ftell();
|
$this->size = $size = $this->ftell();
|
||||||
if ($size === 0) return false;
|
if ($size === 0) return false;
|
||||||
$this->rewind();
|
$this->rewind();
|
||||||
return true;
|
return true;
|
||||||
|
@ -131,6 +131,8 @@ abstract class AbstractBuilder extends TempStream implements IBuilder {
|
|||||||
|
|
||||||
protected bool $built = false, $closed = false;
|
protected bool $built = false, $closed = false;
|
||||||
|
|
||||||
|
protected ?int $size = null;
|
||||||
|
|
||||||
function build(?iterable $rows=null, bool $close=true): bool {
|
function build(?iterable $rows=null, bool $close=true): bool {
|
||||||
$ok = true;
|
$ok = true;
|
||||||
if (!$this->built) {
|
if (!$this->built) {
|
||||||
@ -155,6 +157,10 @@ abstract class AbstractBuilder extends TempStream implements IBuilder {
|
|||||||
if ($output !== null) {
|
if ($output !== null) {
|
||||||
http::download_as(path::filename($output));
|
http::download_as(path::filename($output));
|
||||||
}
|
}
|
||||||
|
$size = $this->size;
|
||||||
|
if ($size !== null) {
|
||||||
|
header("Content-Length: $size");
|
||||||
|
}
|
||||||
$this->sentHeaders = true;
|
$this->sentHeaders = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user