Skip to content

Commit

Permalink
Adjusted HTTP method check for zEcho
Browse files Browse the repository at this point in the history
  • Loading branch information
Simbiat committed Jan 29, 2022
1 parent cdc7649 commit d7c5835
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/HTTP20/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -800,12 +800,12 @@ public function zEcho(string $string, string $cacheStrat = '', bool $exit = true
}
#Send header with length
@header('Content-Length: '.strlen($string));
#Exit if HEAD method was used (by this time all headers should have been sent
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'HEAD') {
exit;
#Some HTTP methods do not support body, thus we need to ensure it's not sent.
$method = $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'] ?? $_SERVER['REQUEST_METHOD'] ?? null;
if (in_array($method, ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'])) {
#Send the output
echo $string;
}
#Send the output
echo $string;
if ($exit) {
exit;
}
Expand Down

0 comments on commit d7c5835

Please sign in to comment.