Skip to content

Commit

Permalink
fix: send headers first
Browse files Browse the repository at this point in the history
  • Loading branch information
loks0n committed Nov 8, 2024
1 parent 6045387 commit d91c598
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,19 +525,11 @@ public function send(string $body = ''): void
return;
}

$this->sent = true;

$serverHeader = $this->headers['Server'] ?? 'Utopia/Http';
$this->addHeader('Server', $serverHeader);
$this->addHeader('X-Debug-Speed', (string) (microtime(true) - $this->startTime));

$this->appendCookies()->appendHeaders();

// Send response
if ($this->disablePayload) {
$this->end();
return;
}
$this->appendCookies();

// Compress body
if (
Expand All @@ -554,6 +546,14 @@ public function send(string $body = ''): void
}
}

$this->appendHeaders();

// Send response
if ($this->disablePayload) {
$this->end();
return;
}

$headerSize = strlen(implode("\n", $this->headers));
$bodyLength = strlen($body);
$this->size += $headerSize + $bodyLength;
Expand Down

0 comments on commit d91c598

Please sign in to comment.