mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Add SERVER_PROTOCOL variable to $_SERVER. Patch by kuzuha. Thanks.
This commit is contained in:
parent
465cb32c4c
commit
2cf34bc9fc
2 changed files with 77 additions and 0 deletions
|
@ -571,6 +571,12 @@ static void sapi_cli_server_register_variables(zval *track_vars_array TSRMLS_DC)
|
||||||
sapi_cli_server_register_variable(track_vars_array, "SERVER_SOFTWARE", tmp TSRMLS_CC);
|
sapi_cli_server_register_variable(track_vars_array, "SERVER_SOFTWARE", tmp TSRMLS_CC);
|
||||||
efree(tmp);
|
efree(tmp);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
char *tmp;
|
||||||
|
spprintf(&tmp, 0, "HTTP/%d.%d", client->request.protocol_version / 100, client->request.protocol_version % 100);
|
||||||
|
sapi_cli_server_register_variable(track_vars_array, "SERVER_PROTOCOL", tmp TSRMLS_CC);
|
||||||
|
efree(tmp);
|
||||||
|
}
|
||||||
sapi_cli_server_register_variable(track_vars_array, "REQUEST_URI", client->request.request_uri TSRMLS_CC);
|
sapi_cli_server_register_variable(track_vars_array, "REQUEST_URI", client->request.request_uri TSRMLS_CC);
|
||||||
sapi_cli_server_register_variable(track_vars_array, "REQUEST_METHOD", SG(request_info).request_method TSRMLS_CC);
|
sapi_cli_server_register_variable(track_vars_array, "REQUEST_METHOD", SG(request_info).request_method TSRMLS_CC);
|
||||||
sapi_cli_server_register_variable(track_vars_array, "PHP_SELF", client->request.vpath TSRMLS_CC);
|
sapi_cli_server_register_variable(track_vars_array, "PHP_SELF", client->request.vpath TSRMLS_CC);
|
||||||
|
|
71
sapi/cli/tests/php_cli_server_008.phpt
Normal file
71
sapi/cli/tests/php_cli_server_008.phpt
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
--TEST--
|
||||||
|
SERVER_PROTOCOL header availability
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
include "skipif.inc";
|
||||||
|
if (substr(PHP_OS, 0, 3) == 'WIN') {
|
||||||
|
die ("skip not for Windows");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
include "php_cli_server.inc";
|
||||||
|
php_cli_server_start('var_dump($_SERVER["SERVER_PROTOCOL"]);');
|
||||||
|
|
||||||
|
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
|
||||||
|
$port = intval($port)?:80;
|
||||||
|
|
||||||
|
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
|
||||||
|
if (!$fp) {
|
||||||
|
die("connect failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fwrite($fp, <<<HEADER
|
||||||
|
GET / HTTP/1.1
|
||||||
|
Host: {$host}
|
||||||
|
|
||||||
|
|
||||||
|
HEADER
|
||||||
|
)) {
|
||||||
|
while (!feof($fp)) {
|
||||||
|
echo fgets($fp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
|
||||||
|
if (!$fp) {
|
||||||
|
die("connect failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(fwrite($fp, <<<HEADER
|
||||||
|
GET / HTTP/1.0
|
||||||
|
Host: {$host}
|
||||||
|
|
||||||
|
|
||||||
|
HEADER
|
||||||
|
)) {
|
||||||
|
while (!feof($fp)) {
|
||||||
|
echo fgets($fp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose($fp);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
HTTP/1.1 200 OK
|
||||||
|
Host: %s
|
||||||
|
Connection: closed
|
||||||
|
X-Powered-By: PHP/%s-dev
|
||||||
|
Content-type: text/html
|
||||||
|
|
||||||
|
string(8) "HTTP/1.1"
|
||||||
|
HTTP/1.0 200 OK
|
||||||
|
Host: %s
|
||||||
|
Connection: closed
|
||||||
|
X-Powered-By: PHP/%s-dev
|
||||||
|
Content-type: text/html
|
||||||
|
|
||||||
|
string(8) "HTTP/1.0"
|
Loading…
Add table
Add a link
Reference in a new issue