diff options
Diffstat (limited to 'sapi/cli')
56 files changed, 626 insertions, 135 deletions
diff --git a/sapi/cli/cli.h b/sapi/cli/cli.h index c571eeb5c5..ea373c2595 100644 --- a/sapi/cli/cli.h +++ b/sapi/cli/cli.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/sapi/cli/config.m4 b/sapi/cli/config.m4 index c5819cd8b4..04db2fecee 100644 --- a/sapi/cli/config.m4 +++ b/sapi/cli/config.m4 @@ -36,9 +36,9 @@ if test "$PHP_CLI" != "no"; then case $host_alias in *aix*) if test "$php_sapi_module" = "shared"; then - BUILD_CLI="echo '\#! .' > php.sym && echo >>php.sym && nm -BCpg \`echo \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_CLI_OBJS) | sed 's/\([A-Za-z0-9_]*\)\.lo/.libs\/\1.o/g'\` | \$(AWK) '{ if (((\$\$2 == \"T\") || (\$\$2 == \"D\") || (\$\$2 == \"B\")) && (substr(\$\$3,1,1) != \".\")) { print \$\$3 } }' | sort -u >> php.sym && \$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) -Wl,-brtl -Wl,-bE:php.sym \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)" + BUILD_CLI="echo '\#! .' > php.sym && echo >>php.sym && nm -BCpg \`echo \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_CLI_OBJS) | sed 's/\([A-Za-z0-9_]*\)\.lo/.libs\/\1.o/g'\` | \$(AWK) '{ if (((\$\$2 == \"T\") || (\$\$2 == \"D\") || (\$\$2 == \"B\")) && (substr(\$\$3,1,1) != \".\")) { print \$\$3 } }' | sort -u >> php.sym && \$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) -Wl,-brtl -Wl,-bE:php.sym \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)" else - BUILD_CLI="echo '\#! .' > php.sym && echo >>php.sym && nm -BCpg \`echo \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_CLI_OBJS) | sed 's/\([A-Za-z0-9_]*\)\.lo/\1.o/g'\` | \$(AWK) '{ if (((\$\$2 == \"T\") || (\$\$2 == \"D\") || (\$\$2 == \"B\")) && (substr(\$\$3,1,1) != \".\")) { print \$\$3 } }' | sort -u >> php.sym && \$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) -Wl,-brtl -Wl,-bE:php.sym \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)" + BUILD_CLI="echo '\#! .' > php.sym && echo >>php.sym && nm -BCpg \`echo \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_CLI_OBJS) | sed 's/\([A-Za-z0-9_]*\)\.lo/\1.o/g'\` | \$(AWK) '{ if (((\$\$2 == \"T\") || (\$\$2 == \"D\") || (\$\$2 == \"B\")) && (substr(\$\$3,1,1) != \".\")) { print \$\$3 } }' | sort -u >> php.sym && \$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) -Wl,-brtl -Wl,-bE:php.sym \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)" fi ;; *darwin*) diff --git a/sapi/cli/config.w32 b/sapi/cli/config.w32 index 664394c8a6..7d0e5954ff 100644 --- a/sapi/cli/config.w32 +++ b/sapi/cli/config.w32 @@ -8,10 +8,16 @@ ARG_ENABLE('cli-win32', 'Build console-less CLI version of PHP', 'no'); if (PHP_CLI == "yes") { SAPI('cli', 'php_cli.c php_http_parser.c php_cli_server.c php_cli_process_title.c ps_title.c', 'php.exe', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1'); ADD_FLAG("LIBS_CLI", "ws2_32.lib"); + ADD_FLAG("LIBS_CLI", "shell32.lib"); if (PHP_CRT_DEBUG == "yes") { ADD_FLAG("CFLAGS_CLI", "/D PHP_WIN32_DEBUG_HEAP"); } ADD_FLAG("LDFLAGS_CLI", "/stack:67108864"); + + if (CHECK_LIB("edit_a.lib;edit.lib", "cli", PHP_CLI) && + CHECK_HEADER_ADD_INCLUDE("editline/readline.h", "CFLAGS_CLI")) { + ADD_FLAG("CFLAGS_CLI", "/D HAVE_LIBEDIT"); + } } if (PHP_CLI_WIN32 == "yes") { diff --git a/sapi/cli/generate_mime_type_map.php b/sapi/cli/generate_mime_type_map.php index 9e088814a0..402be0070c 100644 --- a/sapi/cli/generate_mime_type_map.php +++ b/sapi/cli/generate_mime_type_map.php @@ -27,12 +27,24 @@ array_walk($types, function ($line) use (&$extensions) { } }); +$additional_mime_maps = [ + "map" => "application/json", // from commit: a0d62f08ae8cbebc88e5c92e08fca8d0cdc7309d +]; + +foreach($additional_mime_maps as $ext => $mime) { + if (!isset($extensions[$ext])) { + $extensions[$ext] = $mime; + } else { + printf(STDERR, "Ignored exist mime type: $ext => $mime\n"); + } +} + ?> /* +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/sapi/cli/mime_type_map.h b/sapi/cli/mime_type_map.h index e82fc3fd7f..0afa501429 100644 --- a/sapi/cli/mime_type_map.h +++ b/sapi/cli/mime_type_map.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -1009,6 +1009,7 @@ static php_cli_server_ext_mime_type_pair mime_type_map[] = { { "movie", "video/x-sgi-movie" }, { "smv", "video/x-smv" }, { "ice", "x-conference/x-cooltalk" }, + { "map", "application/json" }, { NULL, NULL } }; diff --git a/sapi/cli/php.1.in b/sapi/cli/php.1.in index c062f3d20e..7b5863a5a5 100644 --- a/sapi/cli/php.1.in +++ b/sapi/cli/php.1.in @@ -1,4 +1,4 @@ -.TH @program_prefix@php 1 "2014" "The PHP Group" "Scripting Language" +.TH @program_prefix@php 1 "2016" "The PHP Group" "Scripting Language" .SH NAME @program_prefix@php \- PHP Command Line Interface 'CLI' .P @@ -454,7 +454,7 @@ contributors all around the world. .SH VERSION INFORMATION This manpage describes \fBphp\fP, version @PHP_VERSION@. .SH COPYRIGHT -Copyright \(co 1997\-2014 The PHP Group +Copyright \(co 1997\-2016 The PHP Group .LP This source file is subject to version 3.01 of the PHP license, that is bundled with this package in the file LICENSE, and is diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 3b2bed8538..dc92045ae7 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -39,6 +39,7 @@ #include "win32/time.h" #include "win32/signal.h" #include <process.h> +#include <shellapi.h> #endif #if HAVE_SYS_TIME_H #include <sys/time.h> @@ -102,8 +103,11 @@ PHPAPI extern char *php_ini_opened_path; PHPAPI extern char *php_ini_scanned_path; PHPAPI extern char *php_ini_scanned_files; -#if defined(PHP_WIN32) && defined(ZTS) -ZEND_TSRMLS_CACHE_DEFINE(); +#if defined(PHP_WIN32) +#if defined(ZTS) +ZEND_TSRMLS_CACHE_DEFINE() +#endif +static DWORD orig_cp = 0; #endif #ifndef O_BINARY @@ -218,8 +222,9 @@ static int print_extension_info(zend_extension *ext, void *arg) /* {{{ */ static int extension_name_cmp(const zend_llist_element **f, const zend_llist_element **s) /* {{{ */ { - return strcmp(((zend_extension *)(*f)->data)->name, - ((zend_extension *)(*s)->data)->name); + zend_extension *fe = (zend_extension*)(*f)->data; + zend_extension *se = (zend_extension*)(*s)->data; + return strcmp(fe->name, se->name); } /* }}} */ @@ -267,11 +272,7 @@ PHP_CLI_API size_t sapi_cli_single_write(const char *str, size_t str_length) /* #endif if (cli_shell_callbacks.cli_shell_write) { - size_t shell_wrote; - shell_wrote = cli_shell_callbacks.cli_shell_write(str, str_length); - if (shell_wrote > -1) { - return shell_wrote; - } + cli_shell_callbacks.cli_shell_write(str, str_length); } #ifdef PHP_WRITE_STDOUT @@ -304,7 +305,7 @@ static size_t sapi_cli_ub_write(const char *str, size_t str_length) /* {{{ */ if (cli_shell_callbacks.cli_shell_ub_write) { size_t ub_wrote; ub_wrote = cli_shell_callbacks.cli_shell_ub_write(str, str_length); - if (ub_wrote > -1) { + if (ub_wrote != (size_t) -1) { return ub_wrote; } } @@ -376,7 +377,7 @@ static void sapi_cli_register_variables(zval *track_vars_array) /* {{{ */ } /* }}} */ -static void sapi_cli_log_message(char *message) /* {{{ */ +static void sapi_cli_log_message(char *message, int syslog_type_int) /* {{{ */ { fprintf(stderr, "%s\n", message); } @@ -487,7 +488,7 @@ static const zend_function_entry additional_functions[] = { ZEND_FE(dl, arginfo_dl) PHP_FE(cli_set_process_title, arginfo_cli_set_process_title) PHP_FE(cli_get_process_title, arginfo_cli_get_process_title) - {NULL, NULL, NULL} + PHP_FE_END }; /* {{{ php_cli_usage @@ -517,7 +518,7 @@ static void php_cli_usage(char *argv0) " -a Run interactively\n" #endif " -c <path>|<file> Look for php.ini file in this directory\n" - " -n No php.ini file will be used\n" + " -n No configuration (ini) files will be used\n" " -d foo[=bar] Define INI entry foo with value 'bar'\n" " -e Generate extended information for debugger/profiler\n" " -f <file> Parse and execute <file>.\n" @@ -557,7 +558,6 @@ static php_stream *s_in_process = NULL; static void cli_register_file_handles(void) /* {{{ */ { - zval zin, zout, zerr; php_stream *s_in, *s_out, *s_err; php_stream_context *sc_in=NULL, *sc_out=NULL, *sc_err=NULL; zend_constant ic, oc, ec; @@ -581,23 +581,20 @@ static void cli_register_file_handles(void) /* {{{ */ s_in_process = s_in; - php_stream_to_zval(s_in, &zin); - php_stream_to_zval(s_out, &zout); - php_stream_to_zval(s_err, &zerr); + php_stream_to_zval(s_in, &ic.value); + php_stream_to_zval(s_out, &oc.value); + php_stream_to_zval(s_err, &ec.value); - ZVAL_COPY_VALUE(&ic.value, &zin); ic.flags = CONST_CS; ic.name = zend_string_init("STDIN", sizeof("STDIN")-1, 1); ic.module_number = 0; zend_register_constant(&ic); - ZVAL_COPY_VALUE(&oc.value, &zout); oc.flags = CONST_CS; oc.name = zend_string_init("STDOUT", sizeof("STDOUT")-1, 1); oc.module_number = 0; zend_register_constant(&oc); - ZVAL_COPY_VALUE(&ec.value, &zerr); ec.flags = CONST_CS; ec.name = zend_string_init("STDERR", sizeof("STDERR")-1, 1); ec.module_number = 0; @@ -646,6 +643,17 @@ static int cli_seek_file_begin(zend_file_handle *file_handle, char *script_file, } /* }}} */ +/*{{{ php_cli_win32_ctrl_handler */ +#if defined(PHP_WIN32) && !defined(PHP_CLI_WIN32_NO_CONSOLE) +BOOL WINAPI php_cli_win32_ctrl_handler(DWORD sig) +{ + (void)php_win32_cp_cli_do_restore(orig_cp); + + return FALSE; +} +#endif +/*}}}*/ + static int do_cli(int argc, char **argv) /* {{{ */ { int c; @@ -682,17 +690,28 @@ static int do_cli(int argc, char **argv) /* {{{ */ goto out; case 'v': /* show php version & quit */ - php_printf("PHP %s (%s) (built: %s %s) %s\nCopyright (c) 1997-2015 The PHP Group\n%s", + php_printf("PHP %s (%s) (built: %s %s) ( %s)\nCopyright (c) 1997-2016 The PHP Group\n%s", PHP_VERSION, cli_sapi_module.name, __DATE__, __TIME__, -#if ZEND_DEBUG && defined(HAVE_GCOV) - "(DEBUG GCOV)", -#elif ZEND_DEBUG - "(DEBUG)", -#elif defined(HAVE_GCOV) - "(GCOV)", +#if ZTS + "ZTS " #else - "", + "NTS " +#endif +#ifdef COMPILER + COMPILER + " " +#endif +#ifdef ARCHITECTURE + ARCHITECTURE + " " #endif +#if ZEND_DEBUG + "DEBUG " +#endif +#ifdef HAVE_GCOV + "GCOV " +#endif + , get_zend_version() ); sapi_deactivate(); @@ -1015,16 +1034,15 @@ static int do_cli(int argc, char **argv) /* {{{ */ if (exec_begin && zend_eval_string_ex(exec_begin, NULL, "Command line begin code", 1) == FAILURE) { exit_status=254; } - ZVAL_LONG(&argi, index); - zend_hash_str_update(&EG(symbol_table), "argi", sizeof("argi")-1, &argi); while (exit_status == SUCCESS && (input=php_stream_gets(s_in_process, NULL, 0)) != NULL) { len = strlen(input); while (len > 0 && len-- && (input[len]=='\n' || input[len]=='\r')) { input[len] = '\0'; } - ZVAL_STRINGL(&argn, input, len); + ZVAL_STRINGL(&argn, input, len + 1); zend_hash_str_update(&EG(symbol_table), "argn", sizeof("argn")-1, &argn); - Z_LVAL(argi) = ++index; + ZVAL_LONG(&argi, ++index); + zend_hash_str_update(&EG(symbol_table), "argi", sizeof("argi")-1, &argi); if (exec_run) { if (zend_eval_string_ex(exec_run, NULL, "Command line run code", 1) == FAILURE) { exit_status=254; @@ -1161,9 +1179,16 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine int main(int argc, char *argv[]) #endif { -#ifdef PHP_CLI_WIN32_NO_CONSOLE +#if defined(PHP_WIN32) +# ifdef PHP_CLI_WIN32_NO_CONSOLE int argc = __argc; char **argv = __argv; +# else + int num_args; + wchar_t **argv_wide; + char **argv_save = argv; + BOOL using_wide_argv = 0; +# endif #endif int c; @@ -1220,6 +1245,8 @@ int main(int argc, char *argv[]) ZEND_TSRMLS_CACHE_UPDATE(); #endif + zend_signal_startup(); + #ifdef PHP_WIN32 _fmode = _O_BINARY; /*sets default for file streams to binary */ setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */ @@ -1326,6 +1353,19 @@ exit_loop: } module_started = 1; +#if defined(PHP_WIN32) && !defined(PHP_CLI_WIN32_NO_CONSOLE) + php_win32_cp_cli_setup(); + orig_cp = (php_win32_cp_get_orig())->id; + /* Ignore the delivered argv and argc, read from W API. This place + might be too late though, but this is the earliest place ATW + we can access the internal charset information from PHP. */ + argv_wide = CommandLineToArgvW(GetCommandLineW(), &num_args); + PHP_WIN32_CP_W_TO_ANY_ARRAY(argv_wide, num_args, argv, argc) + using_wide_argv = 1; + + SetConsoleCtrlHandler(php_cli_win32_ctrl_handler, TRUE); +#endif + /* -e option */ if (use_extended_info) { CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO; @@ -1359,6 +1399,15 @@ out: tsrm_shutdown(); #endif +#if defined(PHP_WIN32) && !defined(PHP_CLI_WIN32_NO_CONSOLE) + (void)php_win32_cp_cli_restore(); + + if (using_wide_argv) { + PHP_WIN32_CP_FREE_ARRAY(argv, argc); + LocalFree(argv_wide); + } + argv = argv_save; +#endif /* * Do not move this de-initialization. It needs to happen right before * exiting. diff --git a/sapi/cli/php_cli_process_title.c b/sapi/cli/php_cli_process_title.c index db614d4323..9323e5e99a 100644 --- a/sapi/cli/php_cli_process_title.c +++ b/sapi/cli/php_cli_process_title.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/sapi/cli/php_cli_process_title.h b/sapi/cli/php_cli_process_title.h index 30091fe2fb..f0a7e23b27 100644 --- a/sapi/cli/php_cli_process_title.h +++ b/sapi/cli/php_cli_process_title.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index f76199af9a..0853db99bb 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -94,8 +94,9 @@ #include "ext/standard/file.h" /* for php_set_sock_blocking() :-( */ #include "zend_smart_str.h" #include "ext/standard/html.h" -#include "ext/standard/url.h" /* for php_url_decode() */ +#include "ext/standard/url.h" /* for php_raw_url_decode() */ #include "ext/standard/php_string.h" /* for php_dirname() */ +#include "ext/date/php_date.h" /* for php_format_date() */ #include "php_network.h" #include "php_http_parser.h" @@ -339,15 +340,24 @@ static void append_http_status_line(smart_str *buffer, int protocol_version, int static void append_essential_headers(smart_str* buffer, php_cli_server_client *client, int persistent) /* {{{ */ { - { - char *val; - if (NULL != (val = zend_hash_str_find_ptr(&client->request.headers, "host", sizeof("host")-1))) { - smart_str_appendl_ex(buffer, "Host", sizeof("Host") - 1, persistent); - smart_str_appendl_ex(buffer, ": ", sizeof(": ") - 1, persistent); - smart_str_appends_ex(buffer, val, persistent); - smart_str_appendl_ex(buffer, "\r\n", 2, persistent); - } + char *val; + struct timeval tv = {0}; + + if (NULL != (val = zend_hash_str_find_ptr(&client->request.headers, "host", sizeof("host")-1))) { + smart_str_appendl_ex(buffer, "Host", sizeof("Host") - 1, persistent); + smart_str_appendl_ex(buffer, ": ", sizeof(": ") - 1, persistent); + smart_str_appends_ex(buffer, val, persistent); + smart_str_appendl_ex(buffer, "\r\n", 2, persistent); } + + if (!gettimeofday(&tv, NULL)) { + zend_string *dt = php_format_date("r", 1, tv.tv_sec, 1); + smart_str_appendl_ex(buffer, "Date: ", 6, persistent); + smart_str_appends_ex(buffer, dt->val, persistent); + smart_str_appendl_ex(buffer, "\r\n", 2, persistent); + zend_string_release(dt); + } + smart_str_appendl_ex(buffer, "Connection: close\r\n", sizeof("Connection: close\r\n") - 1, persistent); } /* }}} */ @@ -472,7 +482,7 @@ const zend_function_entry server_additional_functions[] = { PHP_FE(apache_request_headers, arginfo_no_args) PHP_FE(apache_response_headers, arginfo_no_args) PHP_FALIAS(getallheaders, apache_request_headers, arginfo_no_args) - {NULL, NULL, NULL} + PHP_FE_END }; static int sapi_cli_server_startup(sapi_module_struct *sapi_module) /* {{{ */ @@ -604,6 +614,9 @@ static int sapi_cli_server_register_entry_cb(char **entry, int num_args, va_list } } spprintf(&real_key, 0, "%s_%s", "HTTP", key); + if (strcmp(key, "CONTENT_TYPE") == 0 || strcmp(key, "CONTENT_LENGTH") == 0) { + sapi_cli_server_register_variable(track_vars_array, key, *entry); + } sapi_cli_server_register_variable(track_vars_array, real_key, *entry); efree(key); efree(real_key); @@ -657,10 +670,7 @@ static void sapi_cli_server_register_variables(zval *track_vars_array) /* {{{ */ if (SG(request_info).path_translated) { sapi_cli_server_register_variable(track_vars_array, "SCRIPT_FILENAME", SG(request_info).path_translated); } else if (client->server->router) { - char *temp; - spprintf(&temp, 0, "%s/%s", client->server->document_root, client->server->router); - sapi_cli_server_register_variable(track_vars_array, "SCRIPT_FILENAME", temp); - efree(temp); + sapi_cli_server_register_variable(track_vars_array, "SCRIPT_FILENAME", client->server->router); } if (client->request.path_info) { sapi_cli_server_register_variable(track_vars_array, "PATH_INFO", client->request.path_info); @@ -679,7 +689,7 @@ static void sapi_cli_server_register_variables(zval *track_vars_array) /* {{{ */ zend_hash_apply_with_arguments(&client->request.headers, (apply_func_args_t)sapi_cli_server_register_entry_cb, 1, track_vars_array); } /* }}} */ -static void sapi_cli_server_log_message(char *msg) /* {{{ */ +static void sapi_cli_server_log_message(char *msg, int syslog_type_int) /* {{{ */ { char buf[52]; @@ -992,7 +1002,11 @@ static int php_cli_server_content_sender_send(php_cli_server_content_sender *sen if (nbytes_sent < 0) { *nbytes_sent_total = _nbytes_sent_total; return php_socket_errno(); +#ifdef PHP_WIN32 } else if (nbytes_sent == chunk->data.heap.len) { +#else + } else if (nbytes_sent == (ssize_t)chunk->data.heap.len) { +#endif php_cli_server_chunk_dtor(chunk); pefree(chunk, 1); sender->buffer.first = next; @@ -1015,7 +1029,11 @@ static int php_cli_server_content_sender_send(php_cli_server_content_sender *sen if (nbytes_sent < 0) { *nbytes_sent_total = _nbytes_sent_total; return php_socket_errno(); +#ifdef PHP_WIN32 } else if (nbytes_sent == chunk->data.immortal.len) { +#else + } else if (nbytes_sent == (ssize_t)chunk->data.immortal.len) { +#endif php_cli_server_chunk_dtor(chunk); pefree(chunk, 1); sender->buffer.first = next; @@ -1166,7 +1184,7 @@ static void php_cli_server_logf(const char *format, ...) /* {{{ */ } if (sapi_module.log_message) { - sapi_module.log_message(buf); + sapi_module.log_message(buf, -1); } efree(buf); @@ -1382,7 +1400,7 @@ static void php_cli_server_request_translate_vpath(php_cli_server_request *reque *p = '\0'; q = p; while (q > buf) { - if (!zend_stat(buf, &sb)) { + if (!php_sys_stat(buf, &sb)) { if (sb.st_mode & S_IFDIR) { const char **file = index_files; if (q[-1] != DEFAULT_SLASH) { @@ -1391,7 +1409,7 @@ static void php_cli_server_request_translate_vpath(php_cli_server_request *reque while (*file) { size_t l = strlen(*file); memmove(q, *file, l + 1); - if (!zend_stat(buf, &sb) && (sb.st_mode & S_IFREG)) { + if (!php_sys_stat(buf, &sb) && (sb.st_mode & S_IFREG)) { q += l; break; } @@ -1464,7 +1482,19 @@ static void normalize_vpath(char **retval, size_t *retval_len, const char *vpath return; } - decoded_vpath_end = decoded_vpath + php_url_decode(decoded_vpath, (int)vpath_len); + decoded_vpath_end = decoded_vpath + php_raw_url_decode(decoded_vpath, (int)vpath_len); + +#ifdef PHP_WIN32 + { + char *p = decoded_vpath; + + do { + if (*p == '\\') { + *p = '/'; + } + } while (*p++); + } +#endif p = decoded_vpath; @@ -1680,7 +1710,7 @@ static int php_cli_server_client_read_request(php_cli_server_client *client, cha } client->parser.data = client; nbytes_consumed = php_http_parser_execute(&client->parser, &settings, buf, nbytes_read); - if (nbytes_consumed != nbytes_read) { + if (nbytes_consumed != (size_t)nbytes_read) { if (buf[0] & 0x80 /* SSLv2 */ || buf[0] == 0x16 /* SSLv3/TLSv1 */) { *errstr = estrdup("Unsupported SSL request"); } else { @@ -1832,7 +1862,7 @@ static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server if (!chunk) { goto fail; } - snprintf(chunk->data.heap.p, chunk->data.heap.len, prologue_template, status, status_string, ZSTR_VAL(escaped_request_uri)); + snprintf(chunk->data.heap.p, chunk->data.heap.len, prologue_template, status, status_string); chunk->data.heap.len = strlen(chunk->data.heap.p); php_cli_server_buffer_append(&client->content_sender.buffer, chunk); } @@ -1940,6 +1970,19 @@ static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_serv return php_cli_server_send_error_page(server, client, 400); } +#ifdef PHP_WIN32 + /* The win32 namespace will cut off trailing dots and spaces. Since the + VCWD functionality isn't used here, a sophisticated functionality + would have to be reimplemented to know ahead there are no files + with invalid names there. The simplest is just to forbid invalid + filenames, which is done here. */ + if (client->request.path_translated && + ('.' == client->request.path_translated[client->request.path_translated_len-1] || + ' ' == client->request.path_translated[client->request.path_translated_len-1])) { + return php_cli_server_send_error_page(server, client, 500 TSRMLS_CC); + } +#endif + fd = client->request.path_translated ? open(client->request.path_translated, O_RDONLY): -1; if (fd < 0) { return php_cli_server_send_error_page(server, client, 404); @@ -2035,6 +2078,8 @@ static int php_cli_server_dispatch_router(php_cli_server *server, php_cli_server zend_try { zval retval; + + ZVAL_UNDEF(&retval); if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE, &retval, 1, &zfd)) { if (Z_TYPE(retval) != IS_UNDEF) { decline = Z_TYPE(retval) == IS_FALSE; @@ -2122,12 +2167,8 @@ static int php_cli_server_mime_type_ctor(php_cli_server *server, const php_cli_s zend_hash_init(&server->extension_mime_types, 0, NULL, NULL, 1); for (pair = mime_type_map; pair->ext; pair++) { - size_t ext_len = 0, mime_type_len = 0; - - ext_len = strlen(pair->ext); - mime_type_len = strlen(pair->mime_type); - - zend_hash_str_add_mem(&server->extension_mime_types, pair->ext, ext_len, (void*)pair->mime_type, mime_type_len + 1); + size_t ext_len = strlen(pair->ext); + zend_hash_str_add_ptr(&server->extension_mime_types, pair->ext, ext_len, (void*)pair->mime_type); } return SUCCESS; @@ -2461,7 +2502,7 @@ int do_cli_server(int argc, char **argv) /* {{{ */ if (document_root) { zend_stat_t sb; - if (zend_stat(document_root, &sb)) { + if (php_sys_stat(document_root, &sb)) { fprintf(stderr, "Directory %s does not exist.\n", document_root); return 1; } @@ -2508,6 +2549,7 @@ int do_cli_server(int argc, char **argv) /* {{{ */ #if defined(HAVE_SIGNAL_H) && defined(SIGINT) signal(SIGINT, php_cli_server_sigint_handler); + zend_signal_init(); #endif php_cli_server_do_event_loop(&server); php_cli_server_dtor(&server); diff --git a/sapi/cli/php_cli_server.h b/sapi/cli/php_cli_server.h index 9bbe98e1d5..cdf30bce2a 100644 --- a/sapi/cli/php_cli_server.h +++ b/sapi/cli/php_cli_server.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -33,7 +33,7 @@ ZEND_END_MODULE_GLOBALS(cli_server) #ifdef ZTS #define CLI_SERVER_G(v) ZEND_TSRMG(cli_server_globals_id, zend_cli_server_globals *, v) -ZEND_TSRMLS_CACHE_EXTERN(); +ZEND_TSRMLS_CACHE_EXTERN() #else #define CLI_SERVER_G(v) (cli_server_globals.v) #endif diff --git a/sapi/cli/php_http_parser.c b/sapi/cli/php_http_parser.c index aa9f28638f..59361d0911 100644 --- a/sapi/cli/php_http_parser.c +++ b/sapi/cli/php_http_parser.c @@ -89,6 +89,7 @@ static const char *method_strings[] = , "LOCK" , "MKCOL" , "MOVE" + , "MKCALENDAR" , "PROPFIND" , "PROPPATCH" , "SEARCH" @@ -585,7 +586,7 @@ size_t php_http_parser_execute (php_http_parser *parser, case 'G': parser->method = PHP_HTTP_GET; break; case 'H': parser->method = PHP_HTTP_HEAD; break; case 'L': parser->method = PHP_HTTP_LOCK; break; - case 'M': parser->method = PHP_HTTP_MKCOL; /* or MOVE, MKACTIVITY, MERGE, M-SEARCH */ break; + case 'M': parser->method = PHP_HTTP_MKCOL; /* or MOVE, MKCALENDAR, MKACTIVITY, MERGE, M-SEARCH */ break; case 'N': parser->method = PHP_HTTP_NOTIFY; break; case 'O': parser->method = PHP_HTTP_OPTIONS; break; case 'P': parser->method = PHP_HTTP_POST; /* or PROPFIND or PROPPATCH or PUT */ break; @@ -623,6 +624,8 @@ size_t php_http_parser_execute (php_http_parser *parser, } else if (parser->method == PHP_HTTP_MKCOL) { if (index == 1 && ch == 'O') { parser->method = PHP_HTTP_MOVE; + } else if (index == 3 && ch == 'A') { + parser->method = PHP_HTTP_MKCALENDAR; } else if (index == 1 && ch == 'E') { parser->method = PHP_HTTP_MERGE; } else if (index == 1 && ch == '-') { @@ -1536,7 +1539,7 @@ size_t php_http_parser_execute (php_http_parser *parser, p += to_read - 1; } - if (to_read == parser->content_length) { + if (to_read == (size_t)parser->content_length) { state = s_chunk_data_almost_done; } diff --git a/sapi/cli/php_http_parser.h b/sapi/cli/php_http_parser.h index 402e7e3c83..fa4873abeb 100644 --- a/sapi/cli/php_http_parser.h +++ b/sapi/cli/php_http_parser.h @@ -88,6 +88,7 @@ enum php_http_method , PHP_HTTP_LOCK , PHP_HTTP_MKCOL , PHP_HTTP_MOVE + , PHP_HTTP_MKCALENDAR , PHP_HTTP_PROPFIND , PHP_HTTP_PROPPATCH , PHP_HTTP_SEARCH diff --git a/sapi/cli/ps_title.c b/sapi/cli/ps_title.c index 2d95e494aa..c7cfd2abda 100644 --- a/sapi/cli/ps_title.c +++ b/sapi/cli/ps_title.c @@ -42,6 +42,7 @@ #include "config.w32.h" #include <windows.h> #include <process.h> +#include "win32/codepage.h" #else #include "php_config.h" extern char** environ; @@ -109,8 +110,6 @@ extern char** environ; static char windows_error_details[64]; static char ps_buffer[MAX_PATH]; static const size_t ps_buffer_size = MAX_PATH; -typedef BOOL (WINAPI *MySetConsoleTitle)(LPCTSTR); -typedef DWORD (WINAPI *MyGetConsoleTitle)(LPTSTR, DWORD); #elif defined(PS_USE_CLOBBER_ARGV) static char *ps_buffer; /* will point to argv area */ static size_t ps_buffer_size; /* space determined at run time */ @@ -224,8 +223,10 @@ char** save_ps_args(int argc, char** argv) for (i = 0; i < argc; i++) { new_argv[i] = strdup(argv[i]); - if (!new_argv[i]) + if (!new_argv[i]) { + free(new_argv); goto clobber_error; + } } new_argv[argc] = NULL; @@ -369,22 +370,13 @@ int set_ps_title(const char* title) #ifdef PS_USE_WIN32 { - MySetConsoleTitle set_title = NULL; - HMODULE hMod = LoadLibrary("kernel32.dll"); + wchar_t *ps_buffer_w = php_win32_cp_any_to_w(ps_buffer); - if (!hMod) { + if (!ps_buffer_w || !SetConsoleTitleW(ps_buffer_w)) { return PS_TITLE_WINDOWS_ERROR; } - /* NOTE we don't use _UNICODE*/ - set_title = (MySetConsoleTitle)GetProcAddress(hMod, "SetConsoleTitleA"); - if (!set_title) { - return PS_TITLE_WINDOWS_ERROR; - } - - if (!set_title(ps_buffer)) { - return PS_TITLE_WINDOWS_ERROR; - } + free(ps_buffer_w); } #endif /* PS_USE_WIN32 */ @@ -405,22 +397,23 @@ int get_ps_title(int *displen, const char** string) #ifdef PS_USE_WIN32 { - MyGetConsoleTitle get_title = NULL; - HMODULE hMod = LoadLibrary("kernel32.dll"); + wchar_t ps_buffer_w[MAX_PATH]; + char *tmp; - if (!hMod) { + if (!(ps_buffer_cur_len = GetConsoleTitleW(ps_buffer_w, (DWORD)sizeof(ps_buffer_w)))) { return PS_TITLE_WINDOWS_ERROR; } - /* NOTE we don't use _UNICODE*/ - get_title = (MyGetConsoleTitle)GetProcAddress(hMod, "GetConsoleTitleA"); - if (!get_title) { + tmp = php_win32_cp_conv_w_to_any(ps_buffer_w, PHP_WIN32_CP_IGNORE_LEN, &ps_buffer_cur_len); + if (!tmp) { return PS_TITLE_WINDOWS_ERROR; } - if (!(ps_buffer_cur_len = get_title(ps_buffer, (DWORD)ps_buffer_size))) { - return PS_TITLE_WINDOWS_ERROR; - } + ps_buffer_cur_len = ps_buffer_cur_len > sizeof(ps_buffer)-1 ? sizeof(ps_buffer)-1 : ps_buffer_cur_len; + + memmove(ps_buffer, tmp, ps_buffer_size); + ps_buffer[ps_buffer_cur_len] = '\0'; + free(tmp); } #endif *displen = (int)ps_buffer_cur_len; diff --git a/sapi/cli/ps_title.h b/sapi/cli/ps_title.h index 4a8f6f7002..ee13cbe187 100644 --- a/sapi/cli/ps_title.h +++ b/sapi/cli/ps_title.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/sapi/cli/tests/005.phpt b/sapi/cli/tests/005.phpt index 60af3fc992..5a1e8b8fb1 100644 --- a/sapi/cli/tests/005.phpt +++ b/sapi/cli/tests/005.phpt @@ -4,7 +4,7 @@ show information about class <?php include "skipif.inc"; if (!extension_loaded("reflection")) { - die("skip reflection extension required"); + die("skip reflection extension required"); } ?> --FILE-- @@ -18,7 +18,7 @@ var_dump(`"$php" -n --rc exception`); echo "Done\n"; ?> ---EXPECTF-- +--EXPECTF-- string(40) "Exception: Class unknown does not exist " string(183) "Class [ <internal:Core> class stdClass ] { @@ -40,7 +40,7 @@ string(183) "Class [ <internal:Core> class stdClass ] { } " -string(1544) "Class [ <internal:Core> class Exception implements Throwable ] { +string(1607) "Class [ <internal:Core> class Exception implements Throwable ] { - Constants [0] { } @@ -61,7 +61,7 @@ string(1544) "Class [ <internal:Core> class Exception implements Throwable ] { Property [ <default> private $previous ] } - - Methods [10] { + - Methods [11] { Method [ <internal:Core> final private method __clone ] { } @@ -74,6 +74,9 @@ string(1544) "Class [ <internal:Core> class Exception implements Throwable ] { } } + Method [ <internal:Core> public method __wakeup ] { + } + Method [ <internal:Core, prototype Throwable> final public method getMessage ] { } diff --git a/sapi/cli/tests/006.phpt b/sapi/cli/tests/006.phpt index b86c8a3197..b24da56660 100644 --- a/sapi/cli/tests/006.phpt +++ b/sapi/cli/tests/006.phpt @@ -25,7 +25,7 @@ string(44) "Exception: Extension unknown does not exist " string(37) "Exception: Extension does not exist " -string(%d) "Extension [ <persistent> extension #%d pcre version %d.%d.%d%a ] { +string(%d) "Extension [ <persistent> extension #%d pcre version %s ] { - INI { Entry [ pcre.backtrack_limit <ALL> ] @@ -39,7 +39,7 @@ string(%d) "Extension [ <persistent> extension #%d pcre version %d.%d.%d%a ] { } } - - Constants [14] { + - Constants [15] { Constant [ integer PREG_PATTERN_ORDER ] { 1 } Constant [ integer PREG_SET_ORDER ] { 2 } Constant [ integer PREG_OFFSET_CAPTURE ] { 256 } @@ -53,6 +53,7 @@ string(%d) "Extension [ <persistent> extension #%d pcre version %d.%d.%d%a ] { Constant [ integer PREG_RECURSION_LIMIT_ERROR ] { 3 } Constant [ integer PREG_BAD_UTF8_ERROR ] { 4 } Constant [ integer PREG_BAD_UTF8_OFFSET_ERROR ] { 5 } + Constant [ integer PREG_JIT_STACKLIMIT_ERROR ] { 6 } Constant [ string PCRE_VERSION ] { %s } } diff --git a/sapi/cli/tests/017.phpt b/sapi/cli/tests/017.phpt index efaf977db4..dbddb283a4 100644 --- a/sapi/cli/tests/017.phpt +++ b/sapi/cli/tests/017.phpt @@ -6,6 +6,9 @@ include "skipif.inc"; if (!extension_loaded('readline') || readline_info('done') !== NULL) { die ("skip need readline support using libedit"); } +if(substr(PHP_OS, 0, 3) == 'WIN' ) { + die('skip not for Windows'); +} ?> --FILE-- <?php diff --git a/sapi/cli/tests/argv_mb.phpt b/sapi/cli/tests/argv_mb.phpt new file mode 100644 index 0000000000..e8c47f0972 --- /dev/null +++ b/sapi/cli/tests/argv_mb.phpt @@ -0,0 +1,38 @@ +--TEST-- +Test basic argv multibyte API integration +--SKIPIF-- +<?php +include "skipif.inc"; +if (substr(PHP_OS, 0, 3) != 'WIN') { + die ("skip only for Windows"); +} +?> +--FILE-- +<?php + +$php = getenv('TEST_PHP_EXECUTABLE'); + +$argv_fl = dirname(__FILE__) . DIRECTORY_SEPARATOR . "argv_test.php"; +file_put_contents($argv_fl, "<?php var_dump(\$argv); ?>"); + +var_dump(`$php -n $argv_fl 多字节字符串 マルチバイト文字列 многобайтоваястрока flerbytesträng`); + +@unlink($argv_fl); + +?> +==DONE== +--EXPECTF-- +string(%d) "array(%d) { + [0]=> + string(%d) "%sargv_test.php" + [1]=> + string(18) "多字节字符串" + [2]=> + string(27) "マルチバイト文字列" + [3]=> + string(38) "многобайтоваястрока" + [4]=> + string(15) "flerbytesträng" +} +" +==DONE== diff --git a/sapi/cli/tests/bug43177.phpt b/sapi/cli/tests/bug43177.phpt index 23af545908..e475fb09b4 100644 --- a/sapi/cli/tests/bug43177.phpt +++ b/sapi/cli/tests/bug43177.phpt @@ -61,6 +61,7 @@ HEADER --EXPECTF-- HTTP/1.1 200 OK Host: localhost +Date: %s Connection: close X-Powered-By: %s Content-type: text/html; charset=UTF-8 @@ -68,18 +69,21 @@ Content-type: text/html; charset=UTF-8 OK HTTP/1.0 500 Internal Server Error Host: localhost +Date: %s Connection: close X-Powered-By: %s Content-type: text/html; charset=UTF-8 HTTP/1.0 500 Internal Server Error Host: localhost +Date: %s Connection: close X-Powered-By: %s Content-type: text/html; charset=UTF-8 HTTP/1.0 500 Internal Server Error Host: localhost +Date: %s Connection: close X-Powered-By: %s Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/bug64529.phpt b/sapi/cli/tests/bug64529.phpt index 8452953baf..7331b8303e 100644 --- a/sapi/cli/tests/bug64529.phpt +++ b/sapi/cli/tests/bug64529.phpt @@ -5,6 +5,9 @@ Bug #64529 (Ran out of opcode space) if (substr(PHP_OS, 0, 3) == "WIN") { die("skip non windows test"); } +if (!extension_loaded("readline") || !readline_info("done")) { + die("skip readline support required"); +} exec('which expect', $output, $ret); if ($ret) { die("skip no expect installed"); diff --git a/sapi/cli/tests/bug65066_100.phpt b/sapi/cli/tests/bug65066_100.phpt index 901ba188fd..34381d8e96 100644 --- a/sapi/cli/tests/bug65066_100.phpt +++ b/sapi/cli/tests/bug65066_100.phpt @@ -34,6 +34,7 @@ HEADER --EXPECTF-- HTTP/1.1 100 Continue Host: %s +Date: %s Connection: close X-Powered-By: PHP/%s Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/bug65066_422.phpt b/sapi/cli/tests/bug65066_422.phpt index 4e5d31c7a7..f25ddfbca6 100644 --- a/sapi/cli/tests/bug65066_422.phpt +++ b/sapi/cli/tests/bug65066_422.phpt @@ -34,6 +34,7 @@ HEADER --EXPECTF-- HTTP/1.1 422 Unknown Status Code Host: %s +Date: %s Connection: close X-Powered-By: PHP/%s Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/bug65066_511.phpt b/sapi/cli/tests/bug65066_511.phpt index a0b4eae393..27c9f9755a 100644 --- a/sapi/cli/tests/bug65066_511.phpt +++ b/sapi/cli/tests/bug65066_511.phpt @@ -34,6 +34,7 @@ HEADER --EXPECTF-- HTTP/1.1 511 Network Authentication Required Host: %s +Date: %s Connection: close X-Powered-By: PHP/%s Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/bug65633.phpt b/sapi/cli/tests/bug65633.phpt index 456436b1f7..2e9f2796e8 100644 --- a/sapi/cli/tests/bug65633.phpt +++ b/sapi/cli/tests/bug65633.phpt @@ -37,6 +37,7 @@ fclose($fp); ?> --EXPECTF-- HTTP/1.1 200 OK +Date: %s Connection: close X-Powered-By: %s Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/bug66606_1.phpt b/sapi/cli/tests/bug66606_1.phpt new file mode 100644 index 0000000000..ad35038bae --- /dev/null +++ b/sapi/cli/tests/bug66606_1.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #66606 (Sets HTTP_CONTENT_TYPE but not CONTENT_TYPE) - GET request +--INI-- +allow_url_fopen=1 +--SKIPIF-- +<?php +include "skipif.inc"; +?> +--FILE-- +<?php +include "php_cli_server.inc"; +php_cli_server_start('var_dump($_SERVER["CONTENT_TYPE"], $_SERVER["CONTENT_LENGTH"])'); +echo file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS); +?> +--EXPECTF-- +NULL +NULL diff --git a/sapi/cli/tests/bug66606_2.phpt b/sapi/cli/tests/bug66606_2.phpt new file mode 100644 index 0000000000..c47b7736c0 --- /dev/null +++ b/sapi/cli/tests/bug66606_2.phpt @@ -0,0 +1,47 @@ +--TEST-- +Bug #66606 (Sets HTTP_CONTENT_TYPE but not CONTENT_TYPE) - POST request +--INI-- +allow_url_fopen=1 +--SKIPIF-- +<?php +include "skipif.inc"; +?> +--FILE-- +<?php +include "php_cli_server.inc"; +php_cli_server_start('var_dump($_SERVER["CONTENT_TYPE"], $_SERVER["CONTENT_LENGTH"])'); + +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 +POST /index.php HTTP/1.1 +Host: {$host} +Content-Type: application/x-www-form-urlencoded +Content-Length: 3 + +a=b +HEADER +)) { + while (!feof($fp)) { + echo fgets($fp); + } +} + +fclose($fp); +?> +--EXPECTF-- +HTTP/1.1 200 OK +Host: %s +Date: %s +Connection: close +X-Powered-By: PHP/%s +Content-type: text/html; charset=UTF-8 + +string(33) "application/x-www-form-urlencoded" +string(1) "3" diff --git a/sapi/cli/tests/bug66830.phpt b/sapi/cli/tests/bug66830.phpt index 58c07e031a..b21b33627e 100644 --- a/sapi/cli/tests/bug66830.phpt +++ b/sapi/cli/tests/bug66830.phpt @@ -37,6 +37,7 @@ fclose($fp); --EXPECTF-- HTTP/1.1 200 OK Host: %s +Date: %s Connection: close X-Powered-By: %s Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/bug67429.phpt b/sapi/cli/tests/bug67429.phpt index 856946b29d..2e0b6ad627 100644 --- a/sapi/cli/tests/bug67429.phpt +++ b/sapi/cli/tests/bug67429.phpt @@ -8,8 +8,9 @@ include "skipif.inc"; <?php include "php_cli_server.inc"; +// This creates a new server for each response code foreach ([308, 426] as $code) { - php_cli_server_start(<<<PHP + $proc_handle = php_cli_server_start(<<<PHP http_response_code($code); PHP ); @@ -34,15 +35,21 @@ HEADER } fclose($fp); + // Shutdown the servers or another server may not be able to start + // because of the this server still being bound to the port + + php_cli_server_stop($proc_handle); } ?> --EXPECTF-- HTTP/1.1 308 Permanent Redirect +Date: %s Connection: close X-Powered-By: %s Content-type: text/html; charset=UTF-8 HTTP/1.1 426 Upgrade Required +Date: %s Connection: close X-Powered-By: %s Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/bug68291.phpt b/sapi/cli/tests/bug68291.phpt new file mode 100644 index 0000000000..62042307c5 --- /dev/null +++ b/sapi/cli/tests/bug68291.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #68291 (404 on urls with '+') +--INI-- +allow_url_fopen=1 +--SKIPIF-- +<?php +include "skipif.inc"; +?> +--FILE-- +<?php +include "php_cli_server.inc"; +file_put_contents(__DIR__ . '/bug68291+test.html', 'Found'); +php_cli_server_start(NULL, NULL); +echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/bug68291+test.html'); +?> +--CLEAN-- +<?php +@unlink(__DIR__ . '/bug68291+test.html'); +?> +--EXPECT-- +Found diff --git a/sapi/cli/tests/bug68745.phpt b/sapi/cli/tests/bug68745.phpt index 733d7d0900..4cdfe0ae4e 100644 --- a/sapi/cli/tests/bug68745.phpt +++ b/sapi/cli/tests/bug68745.phpt @@ -27,6 +27,7 @@ fclose($fp); ?> --EXPECTF-- HTTP/1.1 200 OK +Date: %s Connection: close X-Powered-By: %s Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/bug69655.phpt b/sapi/cli/tests/bug69655.phpt index 188b9c31ee..73791c95d5 100644 --- a/sapi/cli/tests/bug69655.phpt +++ b/sapi/cli/tests/bug69655.phpt @@ -10,7 +10,7 @@ include "skipif.inc"; <?php include "php_cli_server.inc"; php_cli_server_start(); -foreach (['MKCALENDAR', 'MKCO', 'MKCOLL', 'M'] as $method) { +foreach (['MKCO', 'MKCOLL', 'M'] as $method) { $context = stream_context_create(['http' => ['method' => $method]]); // the following is supposed to emit a warning for unsupported methods file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS, false, $context); @@ -25,6 +25,3 @@ Warning: file_get_contents(http://localhost:8964): failed to open stream: HTTP r Warning: file_get_contents(http://localhost:8964): failed to open stream: HTTP request failed! HTTP/1.0 501 Not Implemented in %s on line %d - -Warning: file_get_contents(http://localhost:8964): failed to open stream: HTTP request failed! HTTP/1.0 501 Not Implemented - in %s on line %d diff --git a/sapi/cli/tests/bug69953.phpt b/sapi/cli/tests/bug69953.phpt new file mode 100644 index 0000000000..4de41fee40 --- /dev/null +++ b/sapi/cli/tests/bug69953.phpt @@ -0,0 +1,17 @@ +--TEST-- +FR #69953 (Support MKCALENDAR request method) +--INI-- +allow_url_fopen=1 +--SKIPIF-- +<?php +include "skipif.inc"; +?> +--FILE-- +<?php +include "php_cli_server.inc"; +php_cli_server_start('echo $_SERVER["REQUEST_METHOD"];'); +$context = stream_context_create(['http' => ['method' => 'MKCALENDAR']]); +var_dump(file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS, false, $context)); +?> +--EXPECT-- +string(10) "MKCALENDAR" diff --git a/sapi/cli/tests/bug70264.phpt b/sapi/cli/tests/bug70264.phpt new file mode 100644 index 0000000000..877b1194f2 --- /dev/null +++ b/sapi/cli/tests/bug70264.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #70264 (CLI server directory traversal) +--INI-- +allow_url_fopen=1 +--SKIPIF-- +<?php +include "skipif.inc"; +?> +--FILE-- +<?php +include "php_cli_server.inc"; +php_cli_server_start(null, null); +echo file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS . "/..\\CREDITS"); +echo file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS . "/..%5CCREDITS"); +?> +--EXPECTF-- +Warning: file_get_contents(http://%s/..\CREDITS): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found + in %sbug70264.php on line %d + +Warning: file_get_contents(http://%s/..%5CCREDITS): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found + in %sbug70264.php on line %d diff --git a/sapi/cli/tests/bug70470.phpt b/sapi/cli/tests/bug70470.phpt new file mode 100644 index 0000000000..acd8c98f05 --- /dev/null +++ b/sapi/cli/tests/bug70470.phpt @@ -0,0 +1,45 @@ +--TEST-- +Bug #70470 (Built-in server truncates headers spanning over TCP packets) +--SKIPIF-- +<?php +include "skipif.inc"; +?> +--XFAIL-- +bug is not fixed yet +--FILE-- +<?php +include "php_cli_server.inc"; +php_cli_server_start("var_dump(getAllheaders());"); + +$fp = fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT, $errno, $errmsg, 0.5); + +if (!$fp) { + die("connect failed: " . $errmsg); +} + +fwrite($fp, "GET / HTTP/1.1\r\n"); +fwrite($fp, "Host: " . PHP_CLI_SERVER_HOSTNAME . "\r\n"); +fwrite($fp, "Content"); +fflush($fp); +usleep(200000); +fwrite($fp, "-Type: text/html; charset=UTF-8\r\n"); +fwrite($fp, "Connection: clo"); +fflush($fp); +usleep(200000); +fwrite($fp, "se\r\n\r\n"); +while (!feof($fp)) { + echo fgets($fp); +} +fclose($fp); +?> +--EXPECTF-- +HTTP/1.1 200 OK +%a +array(3) { + ["Host"]=> + string(9) "localhost" + ["Content-Type"]=> + string(24) "text/html; charset=UTF-8" + ["Connection"]=> + string(5) "close" +} diff --git a/sapi/cli/tests/bug71005.phpt b/sapi/cli/tests/bug71005.phpt new file mode 100644 index 0000000000..f02f261fbf --- /dev/null +++ b/sapi/cli/tests/bug71005.phpt @@ -0,0 +1,47 @@ +--TEST-- +Bug #71005 (Segfault in php_cli_server_dispatch_router()) +--SKIPIF-- +<?php +include "skipif.inc"; +?> +--FILE-- +<?php + +$code = <<<'EOF' +set_exception_handler(function () { echo 'goodbye'; }); +throw new Exception; +EOF; + +include "php_cli_server.inc"; +php_cli_server_start($code); + +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); + } +} + +?> +--EXPECTF-- +HTTP/1.1 200 OK +Host: %s +Date: %s +Connection: close +X-Powered-By: PHP/%s +Content-type: text/html; charset=UTF-8 + +goodbye diff --git a/sapi/cli/tests/bug71624.phpt b/sapi/cli/tests/bug71624.phpt new file mode 100644 index 0000000000..aa4c69da12 --- /dev/null +++ b/sapi/cli/tests/bug71624.phpt @@ -0,0 +1,43 @@ +--TEST-- +Bug #61977 Test that -R properly sets argi and argn +--SKIPIF-- +<?php +include "skipif.inc"; +?> +--FILE-- +<?php + +$php = getenv('TEST_PHP_EXECUTABLE'); + +$filename_txt = dirname(__FILE__) . DIRECTORY_SEPARATOR . "bug71624.test.txt"; + +$txt = 'foo +test +hello +'; + +file_put_contents($filename_txt, $txt); + +$test_args = ['$argi', '$argn']; +foreach ($test_args as $test_arg) { + if (substr(PHP_OS, 0, 3) == 'WIN') { + var_dump(`type "$filename_txt" | "$php" -n -R "echo $test_arg . PHP_EOL;"`); + } else { + var_dump(`cat "$filename_txt" | "$php" -n -R 'echo $test_arg . PHP_EOL;'`); + } +} + +@unlink($filename_txt); + +echo "Done\n"; +?> +--EXPECT-- +string(6) "1 +2 +3 +" +string(15) "foo +test +hello +" +Done diff --git a/sapi/cli/tests/cli_process_title_unix.phpt b/sapi/cli/tests/cli_process_title_unix.phpt index c2632704c5..659299c1fc 100644 --- a/sapi/cli/tests/cli_process_title_unix.phpt +++ b/sapi/cli/tests/cli_process_title_unix.phpt @@ -15,7 +15,12 @@ $pid = getmypid(); if (cli_set_process_title($original_title) === true) echo "Successfully set title\n"; -$ps_output = shell_exec("ps -p $pid -o command | tail -n 1"); +$ps_process_title_field = "command"; +if (strtoupper(substr(PHP_OS, 0, 3)) == "AIX") +{ + $ps_process_title_field = "args"; +} +$ps_output = shell_exec("ps -p $pid -o $ps_process_title_field | tail -n 1"); if ($ps_output === null) { diff --git a/sapi/cli/tests/cli_process_title_windows.phpt b/sapi/cli/tests/cli_process_title_windows.phpt index 12eb80756d..4e81b4c634 100644 --- a/sapi/cli/tests/cli_process_title_windows.phpt +++ b/sapi/cli/tests/cli_process_title_windows.phpt @@ -21,7 +21,7 @@ if (shell_exec('PowerShell -Help') === NULL) // cli_set_process_title(). We're only making the API calls to ensure there are // no warnings/errors. -$is_windows8 = false; +$is_windows8_or_above = false; $ps_output = shell_exec("PowerShell -NoProfile \"(Get-Host).UI.RawUI.WindowTitle\""); if ($ps_output === null) { @@ -31,8 +31,8 @@ if ($ps_output === null) $ps_output = trim($ps_output); $end_title_windows8 = ": Windows PowerShell"; -if (($ps_output == "Windows PowerShell") || (strlen($ps_output) > strlen($end_title_windows8) && substr($ps_output,-strlen($end_title_windows8)) === $end_title_windows8)) - $is_windows8 = true; +if (($ps_output == "Windows PowerShell") || (strlen($ps_output) > strlen($end_title_windows8) && substr($ps_output,-strlen($end_title_windows8)) === $end_title_windows8) || PHP_WINDOWS_VERSION_MAJOR >= 10) + $is_windows8_or_above = true; echo "*** Testing setting the process title ***\n"; @@ -42,7 +42,7 @@ $pid = getmypid(); if (cli_set_process_title($original_title) === true) echo "Successfully set title\n"; -if ($is_windows8) +if ($is_windows8_or_above) { $loaded_title = $original_title; } @@ -82,4 +82,4 @@ else *** Testing setting the process title *** Successfully set title Successfully verified title using get-process -Successfully verified title using get
\ No newline at end of file +Successfully verified title using get diff --git a/sapi/cli/tests/php_cli_server.inc b/sapi/cli/tests/php_cli_server.inc index 6b1e90c4dc..6e7b70cb60 100644 --- a/sapi/cli/tests/php_cli_server.inc +++ b/sapi/cli/tests/php_cli_server.inc @@ -33,29 +33,62 @@ function php_cli_server_start($code = 'echo "Hello world";', $router = 'index.ph $handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root); } - - // note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.' - // it might not be listening yet...need to wait until fsockopen() call returns - $i = 0; - while (($i++ < 30) && !($fp = @fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT))) { - usleep(10000); + + // note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.' + // it might not be listening yet...need to wait until fsockopen() call returns + $error = "Unable to connect to servers\n"; + for ($i=0; $i < 60; $i++) { + usleep(25000); // 25ms per try + $status = proc_get_status($handle); + $fp = @fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT); + // Failure, the server is no longer running + if (!($status && $status['running'])) { + $error = "Server is not running\n"; + break; + } + // Success, Connected to servers + if ($fp) { + $error = ''; + break; + } } if ($fp) { fclose($fp); } - register_shutdown_function( - function($handle) use($router) { - proc_terminate($handle); - @unlink(__DIR__ . "/{$router}"); - }, - $handle - ); - // don't bother sleeping, server is already up - // server can take a variable amount of time to be up, so just sleeping a guessed amount of time - // does not work. this is why tests sometimes pass and sometimes fail. to get a reliable pass - // sleeping doesn't work. + if ($error) { + echo $error; + proc_terminate($handle); + exit(1); + } + + register_shutdown_function( + function($handle) use($router) { + proc_terminate($handle); + @unlink(__DIR__ . "/{$router}"); + }, + $handle + ); + + return $handle; +} + +function php_cli_server_stop($handle) { + $success = FALSE; + if ($handle) { + proc_terminate($handle); + /* Wait for server to shutdown */ + for ($i = 0; $i < 60; $i++) { + $status = proc_get_status($handle); + if (!($status && $status['running'])) { + $success = TRUE; + break; + } + usleep(25000); + } + } + return $success; } ?> diff --git a/sapi/cli/tests/php_cli_server_004.phpt b/sapi/cli/tests/php_cli_server_004.phpt index 8b913f6596..5e3bbec18f 100644 --- a/sapi/cli/tests/php_cli_server_004.phpt +++ b/sapi/cli/tests/php_cli_server_004.phpt @@ -38,6 +38,7 @@ HEADER --EXPECTF-- HTTP/1.1 200 OK Host: %s +Date: %s Connection: close X-Powered-By: PHP/%s Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/php_cli_server_005.phpt b/sapi/cli/tests/php_cli_server_005.phpt index cdd0ae902f..3f9078c8ae 100644 --- a/sapi/cli/tests/php_cli_server_005.phpt +++ b/sapi/cli/tests/php_cli_server_005.phpt @@ -50,6 +50,7 @@ HEADER --EXPECTF-- HTTP/1.1 200 OK Host: %s +Date: %s Connection: close X-Powered-By: PHP/%s Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/php_cli_server_006.phpt b/sapi/cli/tests/php_cli_server_006.phpt index ad6d6c9598..c68f1e51b0 100644 --- a/sapi/cli/tests/php_cli_server_006.phpt +++ b/sapi/cli/tests/php_cli_server_006.phpt @@ -34,6 +34,7 @@ HEADER --EXPECTF-- HTTP/1.1 200 OK Host: %s +Date: %s Connection: close X-Powered-By: PHP/%s Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/php_cli_server_007.phpt b/sapi/cli/tests/php_cli_server_007.phpt index 6420ff5a41..b588b9ee2e 100644 --- a/sapi/cli/tests/php_cli_server_007.phpt +++ b/sapi/cli/tests/php_cli_server_007.phpt @@ -34,6 +34,7 @@ HEADER --EXPECTF-- HTTP/1.1 401 Unauthorized Host: %s +Date: %s Connection: close X-Powered-By: PHP/%s WWW-Authenticate: Digest realm="foo",qop="auth",nonce="XXXXX",opaque="acbd18db4cc2f85cedef654fccc4a4d8" diff --git a/sapi/cli/tests/php_cli_server_008.phpt b/sapi/cli/tests/php_cli_server_008.phpt index 01f825a746..58b2485db5 100644 --- a/sapi/cli/tests/php_cli_server_008.phpt +++ b/sapi/cli/tests/php_cli_server_008.phpt @@ -54,6 +54,7 @@ fclose($fp); --EXPECTF-- HTTP/1.1 200 OK Host: %s +Date: %s Connection: close X-Powered-By: PHP/%s Content-type: text/html; charset=UTF-8 @@ -61,6 +62,7 @@ Content-type: text/html; charset=UTF-8 string(8) "HTTP/1.1" HTTP/1.0 200 OK Host: %s +Date: %s Connection: close X-Powered-By: PHP/%s Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/php_cli_server_009.phpt b/sapi/cli/tests/php_cli_server_009.phpt index 7f3009b9bd..d63c6abf28 100644 --- a/sapi/cli/tests/php_cli_server_009.phpt +++ b/sapi/cli/tests/php_cli_server_009.phpt @@ -78,6 +78,7 @@ fclose($fp); --EXPECTF-- HTTP/1.1 200 OK Host: %s +Date: %s Connection: close X-Powered-By: PHP/%s Content-type: text/html; charset=UTF-8 @@ -85,6 +86,7 @@ Content-type: text/html; charset=UTF-8 string(8) "/foo/bar" HTTP/1.0 200 OK Host: %s +Date: %s Connection: close X-Powered-By: PHP/%s Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/php_cli_server_010.phpt b/sapi/cli/tests/php_cli_server_010.phpt index ce3abeb501..fe8f1a98ca 100644 --- a/sapi/cli/tests/php_cli_server_010.phpt +++ b/sapi/cli/tests/php_cli_server_010.phpt @@ -55,6 +55,7 @@ fclose($fp); --EXPECTF-- HTTP/1.1 200 OK Host: %s +Date: %s Connection: close X-Powered-By: PHP/%s Content-type: text/html; charset=UTF-8 @@ -65,6 +66,7 @@ string(8) "/foo/bar" string(7) "foo=bar" HTTP/1.0 200 OK Host: %s +Date: %s Connection: close X-Powered-By: PHP/%s Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/php_cli_server_012.phpt b/sapi/cli/tests/php_cli_server_012.phpt index 302540f7e6..10b9cdbfe9 100644 --- a/sapi/cli/tests/php_cli_server_012.phpt +++ b/sapi/cli/tests/php_cli_server_012.phpt @@ -40,6 +40,7 @@ fclose($fp); --EXPECTF-- HTTP/1.1 200 OK Host: %s +Date: %s Connection: close X-Powered-By: PHP/%s Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/php_cli_server_013.phpt b/sapi/cli/tests/php_cli_server_013.phpt index 3ea3ea9cad..23269580fb 100644 --- a/sapi/cli/tests/php_cli_server_013.phpt +++ b/sapi/cli/tests/php_cli_server_013.phpt @@ -83,6 +83,7 @@ fclose($fp); HTTP/1.1 404 Not Found Host: %s +Date: %s Connection: close Content-Type: text/html; charset=UTF-8 Content-Length: %d @@ -91,6 +92,7 @@ Content-Length: %d </head><body><h1>Not Found</h1><p>The requested resource <code class="url">/</code> was not found on this server.</p></body></html> HTTP/1.1 404 Not Found Host: %s +Date: %s Connection: close Content-Type: text/html; charset=UTF-8 Content-Length: %d @@ -99,6 +101,7 @@ Content-Length: %d </head><body><h1>Not Found</h1><p>The requested resource <code class="url">/main/style.css</code> was not found on this server.</p></body></html> HTTP/1.1 404 Not Found Host: %s +Date: %s Connection: close Content-Type: text/html; charset=UTF-8 Content-Length: %d diff --git a/sapi/cli/tests/php_cli_server_014.phpt b/sapi/cli/tests/php_cli_server_014.phpt index 4f812e2f63..7c50a5e30a 100644 --- a/sapi/cli/tests/php_cli_server_014.phpt +++ b/sapi/cli/tests/php_cli_server_014.phpt @@ -65,6 +65,7 @@ fclose($fp); HTTP/1.1 200 OK Host: %s +Date: %s Connection: close X-Powered-By: %s Content-type: %s @@ -72,6 +73,7 @@ Content-type: %s done HTTP/1.1 404 Not Found Host: %s +Date: %s Connection: close Content-Type: %s Content-Length: %d diff --git a/sapi/cli/tests/php_cli_server_015.phpt b/sapi/cli/tests/php_cli_server_015.phpt index af0a3f65a8..663268aea6 100644 --- a/sapi/cli/tests/php_cli_server_015.phpt +++ b/sapi/cli/tests/php_cli_server_015.phpt @@ -41,6 +41,7 @@ fclose($fp); --EXPECTF-- HTTP/1.1 200 OK Host: %s +Date: %s Connection: close X-Powered-By: PHP/%s Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/php_cli_server_017.phpt b/sapi/cli/tests/php_cli_server_017.phpt index 34e7d5e289..28876dc52b 100644 --- a/sapi/cli/tests/php_cli_server_017.phpt +++ b/sapi/cli/tests/php_cli_server_017.phpt @@ -37,6 +37,7 @@ fclose($fp); --EXPECTF-- HTTP/1.1 200 OK Host: %s +Date: %s Connection: close X-Powered-By: %s Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/php_cli_server_018.phpt b/sapi/cli/tests/php_cli_server_018.phpt index 44e1292934..acfb0f2ce3 100644 --- a/sapi/cli/tests/php_cli_server_018.phpt +++ b/sapi/cli/tests/php_cli_server_018.phpt @@ -37,6 +37,7 @@ fclose($fp); --EXPECTF-- HTTP/1.1 200 OK Host: %s +Date: %s Connection: close X-Powered-By: %s Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/php_cli_server_019.phpt b/sapi/cli/tests/php_cli_server_019.phpt index aeb7a9f891..7be87a86c9 100644 --- a/sapi/cli/tests/php_cli_server_019.phpt +++ b/sapi/cli/tests/php_cli_server_019.phpt @@ -41,6 +41,7 @@ fclose($fp); --EXPECTF-- HTTP/1.1 200 OK Host: %s +Date: %s Connection: close X-Powered-By: %s Bar-Foo: Foo diff --git a/sapi/cli/tests/php_cli_server_020.phpt b/sapi/cli/tests/php_cli_server_020.phpt index 4ed673d380..766c666911 100644 --- a/sapi/cli/tests/php_cli_server_020.phpt +++ b/sapi/cli/tests/php_cli_server_020.phpt @@ -33,6 +33,7 @@ HEADER --EXPECTF-- HTTP/1.1 200 OK Host: %s +Date: %s Connection: close X-Powered-By: PHP/%s Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/upload_2G.phpt b/sapi/cli/tests/upload_2G.phpt index 313dcd5ac1..21dacb439a 100644 --- a/sapi/cli/tests/upload_2G.phpt +++ b/sapi/cli/tests/upload_2G.phpt @@ -21,6 +21,10 @@ if ($f = fopen("/proc/meminfo","r")) { if (empty($enough_free_ram)) { die("skip need +3G free RAM"); } + +if (getenv('TRAVIS')) { + die("skip Fails intermittently on travis"); +} ?> --FILE-- <?php @@ -77,6 +81,7 @@ Test HTTP/1.1 200 OK Host: %s +Date: %s Connection: close X-Powered-By: PHP/%s Content-type: text/html; charset=UTF-8 |
