Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion sapi/fpm/fpm/fpm_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ int fpm_status_export_to_zval(zval *status)
int i;

scoreboard_p = fpm_scoreboard_copy(NULL, 1);
if (!scoreboard_p) {
return -1;
}

now_epoch = time(NULL);
fpm_clock_get(&now);
Expand Down Expand Up @@ -180,17 +183,19 @@ int fpm_status_handle_request(void) /* {{{ */
sapi_add_header_ex(ZEND_STRL("Expires: Thu, 01 Jan 1970 00:00:00 GMT"), 1, 1);
sapi_add_header_ex(ZEND_STRL("Cache-Control: no-cache, no-store, must-revalidate, max-age=0"), 1, 1);
PUTS("Internal error. Please review log file for errors.");
zend_string_release_ex(_GET_str, 0);
return 1;
}

if (scoreboard_p->idle < 0 || scoreboard_p->active < 0) {
fpm_scoreboard_free_copy(scoreboard_p);
zlog(ZLOG_ERROR, "[pool %s] invalid status values", scoreboard_p->pool);
SG(sapi_headers).http_response_code = 500;
sapi_add_header_ex(ZEND_STRL("Content-Type: text/plain"), 1, 1);
sapi_add_header_ex(ZEND_STRL("Expires: Thu, 01 Jan 1970 00:00:00 GMT"), 1, 1);
sapi_add_header_ex(ZEND_STRL("Cache-Control: no-cache, no-store, must-revalidate, max-age=0"), 1, 1);
PUTS("Internal error. Please review log file for errors.");
zend_string_release_ex(_GET_str, 0);
fpm_scoreboard_free_copy(scoreboard_p);
return 1;
}

Expand All @@ -201,6 +206,7 @@ int fpm_status_handle_request(void) /* {{{ */

/* handle HEAD */
if (SG(request_info).headers_only) {
zend_string_release_ex(_GET_str, 0);
Comment thread
1ma marked this conversation as resolved.
fpm_scoreboard_free_copy(scoreboard_p);
return 1;
}
Expand Down
40 changes: 40 additions & 0 deletions sapi/fpm/tests/status-head.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
--TEST--
FPM: Status HEAD request returns headers without body
--SKIPIF--
<?php include "skipif.inc"; ?>
--FILE--
<?php

require_once "tester.inc";

$cfg = <<<EOT
[global]
error_log = {{FILE:LOG}}
[unconfined]
listen = {{ADDR}}
pm = static
pm.max_children = 1
pm.status_path = /status
EOT;

$tester = new FPM\Tester($cfg);
$tester->start();
$tester->expectLogStartNotices();
$tester->request()->expectEmptyBody();

$response = $tester->request(uri: '/status', method: 'HEAD');
$response->expectEmptyBody();

$tester->terminate();
$tester->expectLogTerminatingNotices();
$tester->close();

?>
Done
--EXPECT--
Done
--CLEAN--
<?php
require_once "tester.inc";
FPM\Tester::clean();
?>
Loading