laruence Tue, 15 Nov 2011 03:15:19 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=319224
Log:
Fixed bug #60159 (Router returns false, but POST is not passed to requested
resource) and bug #55759 (mem leak when use built-in server)
Bugs: https://bugs.php.net/60159 (Open) Router returns false, but POST is not
passed to requested resource
https://bugs.php.net/55759 (Assigned) mem leak when use built-in server
Changed paths:
U php/php-src/branches/PHP_5_4/NEWS
U php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
A php/php-src/branches/PHP_5_4/sapi/cli/tests/php_cli_server_012.phpt
A php/php-src/branches/PHP_5_4/sapi/cli/tests/php_cli_server_013.phpt
U php/php-src/trunk/sapi/cli/php_cli_server.c
U php/php-src/trunk/sapi/cli/tests/php_cli_server.inc
A php/php-src/trunk/sapi/cli/tests/php_cli_server_012.phpt
A php/php-src/trunk/sapi/cli/tests/php_cli_server_013.phpt
Modified: php/php-src/branches/PHP_5_4/NEWS
===================================================================
--- php/php-src/branches/PHP_5_4/NEWS 2011-11-15 01:53:16 UTC (rev 319223)
+++ php/php-src/branches/PHP_5_4/NEWS 2011-11-15 03:15:19 UTC (rev 319224)
@@ -19,6 +19,11 @@
. Fixed bug #60282 (Segfault when using ob_gzhandler() with open buffers).
(Laruence)
+-CLI SAPI:
+ . Fixed bug #60159 (Router returns false, but POST is not passed to requested
+ resource). (Laruence)
+ . Fixed bug #55759 (mem leak when use built-in server). (Laruence)
+
11 Nov 2011, PHP 5.4.0 RC1
- General improvements:
. Changed silent conversion of array to string to produce a notice. (Patrick)
Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===================================================================
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c 2011-11-15 01:53:16 UTC (rev 319223)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c 2011-11-15 03:15:19 UTC (rev 319224)
@@ -1815,22 +1815,8 @@
static int php_cli_server_dispatch_script(php_cli_server *server, php_cli_server_client *client TSRMLS_DC) /* {{{ */
{
- php_cli_server_client_populate_request_info(client, &SG(request_info));
- {
- char **auth;
- if (SUCCESS == zend_hash_find(&client->request.headers, "Authorization", sizeof("Authorization"), (void**)&auth)) {
- php_handle_auth_data(*auth TSRMLS_CC);
- }
- }
- SG(sapi_headers).http_response_code = 200;
- if (FAILURE == php_request_startup(TSRMLS_C)) {
- /* should never be happen */
- destroy_request_info(&SG(request_info));
- return FAILURE;
- }
if (strlen(client->request.path_translated) != client->request.path_translated_len) {
/* can't handle paths that contain nul bytes */
- destroy_request_info(&SG(request_info));
return php_cli_server_send_error_page(server, client, 400 TSRMLS_CC);
}
{
@@ -1846,9 +1832,6 @@
}
php_cli_server_log_response(client, SG(sapi_headers).http_response_code, NULL TSRMLS_CC);
- php_request_shutdown(0);
- php_cli_server_close_connection(server, client TSRMLS_CC);
- destroy_request_info(&SG(request_info));
return SUCCESS;
} /* }}} */
@@ -1910,27 +1893,35 @@
}
/* }}} */
-static int php_cli_server_dispatch_router(php_cli_server *server, php_cli_server_client *client TSRMLS_DC) /* {{{ */
-{
- int decline = 0;
-
- if (!server->router) {
- return 1;
- }
-
+static int php_cli_server_request_startup(php_cli_server *server, php_cli_server_client *client TSRMLS_DC) { /* {{{ */
+ char **auth;
php_cli_server_client_populate_request_info(client, &SG(request_info));
- {
- char **auth;
- if (SUCCESS == zend_hash_find(&client->request.headers, "Authorization", sizeof("Authorization"), (void**)&auth)) {
- php_handle_auth_data(*auth TSRMLS_CC);
- }
+ if (SUCCESS == zend_hash_find(&client->request.headers, "Authorization", sizeof("Authorization"), (void**)&auth)) {
+ php_handle_auth_data(*auth TSRMLS_CC);
}
SG(sapi_headers).http_response_code = 200;
if (FAILURE == php_request_startup(TSRMLS_C)) {
/* should never be happen */
destroy_request_info(&SG(request_info));
- return -1;
+ return FAILURE;
}
+
+ return SUCCESS;
+}
+/* }}} */
+
+static int php_cli_server_request_shutdown(php_cli_server *server, php_cli_server_client *client TSRMLS_DC) { /* {{{ */
+ php_request_shutdown(0);
+ php_cli_server_close_connection(server, client TSRMLS_CC);
+ destroy_request_info(&SG(request_info));
+ SG(server_context) = NULL;
+ return SUCCESS;
+}
+/* }}} */
+
+static int php_cli_server_dispatch_router(php_cli_server *server, php_cli_server_client *client TSRMLS_DC) /* {{{ */
+{
+ int decline = 0;
if (!php_handle_special_queries(TSRMLS_C)) {
zend_file_handle zfd;
char *old_cwd;
@@ -1965,45 +1956,52 @@
free_alloca(old_cwd, use_heap);
}
- if (decline) {
- php_request_shutdown_for_hook(0);
- } else {
- php_request_shutdown(0);
- php_cli_server_close_connection(server, client TSRMLS_CC);
- }
- destroy_request_info(&SG(request_info));
-
- return decline ? 1: 0;
+ return decline;
}
/* }}} */
static int php_cli_server_dispatch(php_cli_server *server, php_cli_server_client *client TSRMLS_DC) /* {{{ */
{
- int status;
+ int is_static_file = 0;
SG(server_context) = client;
- status = php_cli_server_dispatch_router(server, client TSRMLS_CC);
+ if (client->request.ext_len != 3 || memcmp(client->request.ext, "php", 3) || !client->request.path_translated) {
+ is_static_file = 1;
+ }
- if (status < 0) {
- goto fail;
- } else if (status > 0) {
- if (client->request.ext_len == 3 && memcmp(client->request.ext, "php", 3) == 0 && client->request.path_translated) {
- if (SUCCESS != php_cli_server_dispatch_script(server, client TSRMLS_CC) &&
- SUCCESS != php_cli_server_send_error_page(server, client, 500 TSRMLS_CC)) {
- goto fail;
- }
- } else {
- if (SUCCESS != php_cli_server_begin_send_static(server, client TSRMLS_CC)) {
- goto fail;
- }
+ if (server->router || !is_static_file) {
+ if (FAILURE == php_cli_server_request_startup(server, client TSRMLS_CC)) {
+ SG(server_context) = NULL;
+ php_cli_server_close_connection(server, client TSRMLS_CC);
+ destroy_request_info(&SG(request_info));
+ return SUCCESS;
}
+ }
+
+ if (server->router) {
+ if (!php_cli_server_dispatch_router(server, client TSRMLS_CC)) {
+ php_cli_server_request_shutdown(server, client TSRMLS_CC);
+ return SUCCESS;
+ }
}
- SG(server_context) = 0;
+
+ if (!is_static_file) {
+ if (SUCCESS == php_cli_server_dispatch_script(server, client TSRMLS_CC)
+ || SUCCESS != php_cli_server_send_error_page(server, client, 500 TSRMLS_CC)) {
+ php_cli_server_request_shutdown(server, client TSRMLS_CC);
+ return SUCCESS;
+ }
+ } else {
+ if (SUCCESS != php_cli_server_begin_send_static(server, client TSRMLS_CC)) {
+ php_cli_server_close_connection(server, client TSRMLS_CC);
+ }
+ SG(server_context) = NULL;
+ return SUCCESS;
+ }
+
+ SG(server_context) = NULL;
+ destroy_request_info(&SG(request_info));
return SUCCESS;
-fail:
- SG(server_context) = 0;
- php_cli_server_close_connection(server, client TSRMLS_CC);
- return SUCCESS;
}
/* }}} */
Added: php/php-src/branches/PHP_5_4/sapi/cli/tests/php_cli_server_012.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/sapi/cli/tests/php_cli_server_012.phpt (rev 0)
+++ php/php-src/branches/PHP_5_4/sapi/cli/tests/php_cli_server_012.phpt 2011-11-15 03:15:19 UTC (rev 319224)
@@ -0,0 +1,55 @@
+--TEST--
+Bug #60159 (Router returns false, but POST is not passed to requested resource)
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+include "php_cli_server.inc";
+php_cli_server_start('print_r($_REQUEST); $_REQUEST["foo"] = "bar"; return FALSE;');
+$doc_root = __DIR__;
+file_put_contents($doc_root . '/request.php', '<?php print_r($_REQUEST); ?>');
+
+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 /request.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);
+@unlink($doc_root . '/request.php');
+
+?>
+--EXPECTF--
+HTTP/1.1 200 OK
+Host: %s
+Connection: closed
+X-Powered-By: PHP/%s
+Content-type: text/html
+
+Array
+(
+ [a] => b
+)
+Array
+(
+ [a] => b
+ [foo] => bar
+)
Added: php/php-src/branches/PHP_5_4/sapi/cli/tests/php_cli_server_013.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/sapi/cli/tests/php_cli_server_013.phpt (rev 0)
+++ php/php-src/branches/PHP_5_4/sapi/cli/tests/php_cli_server_013.phpt 2011-11-15 03:15:19 UTC (rev 319224)
@@ -0,0 +1,108 @@
+--TEST--
+No router, no script
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+include "php_cli_server.inc";
+php_cli_server_start(NULL, TRUE);
+
+list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
+$port = intval($port)?:80;
+$output = '';
+
+$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
+if (!$fp) {
+ die("connect failed");
+}
+
+
+if(fwrite($fp, <<<HEADER
+POST / HTTP/1.1
+Host: {$host}
+Content-Type: application/x-www-form-urlencoded
+Content-Length: 3
+
+a=b
+HEADER
+)) {
+ while (!feof($fp)) {
+ $output .= fgets($fp);
+ }
+}
+
+echo preg_replace("/<style type=\"text\/css\">(.*?)<\/style>/s", "<style type=\"text/css\">AAA</style>", $output), "\n";
+fclose($fp);
+
+
+$output = '';
+$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
+if (!$fp) {
+ die("connect failed");
+}
+
+if(fwrite($fp, <<<HEADER
+GET /main/style.css HTTP/1.1
+Host: {$host}
+
+
+HEADER
+)) {
+ while (!feof($fp)) {
+ $output .= fgets($fp);
+ }
+}
+
+echo preg_replace("/<style type=\"text\/css\">(.*?)<\/style>/s", "<style type=\"text/css\">AAA</style>", $output), "\n";
+fclose($fp);
+
+$output = '';
+$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
+if (!$fp) {
+ die("connect failed");
+}
+
+if(fwrite($fp, <<<HEADER
+HEAD /main/foo/bar HTTP/1.1
+Host: {$host}
+
+
+HEADER
+)) {
+ while (!feof($fp)) {
+ $output .= fgets($fp);
+ }
+}
+
+echo preg_replace("/<style type=\"text\/css\">(.*?)<\/style>/s", "<style type=\"text/css\">AAA</style>", $output), "\n";
+fclose($fp);
+?>
+--EXPECTF--
+
+HTTP/1.1 404 Not Found
+Host: %s
+Connection: closed
+Content-Type: text/html; charset=UTF-8
+Content-Length: %d
+
+<html><head><title>404 Not Found</title><style type="text/css">AAA</style>
+</head><body><h1 class="h">Not Found</h1><p>The requested resource / was not found on this server.</p></body></html>
+HTTP/1.1 404 Not Found
+Host: %s
+Connection: closed
+Content-Type: text/html; charset=UTF-8
+Content-Length: %d
+
+<html><head><title>404 Not Found</title><style type="text/css">AAA</style>
+</head><body><h1 class="h">Not Found</h1><p>The requested resource /main/style.css was not found on this server.</p></body></html>
+HTTP/1.1 404 Not Found
+Host: %s
+Connection: closed
+Content-Type: text/html; charset=UTF-8
+Content-Length: %d
+
+<html><head><title>404 Not Found</title><style type="text/css">AAA</style>
+</head><body><h1 class="h">Not Found</h1><p>The requested resource /main/foo/bar was not found on this server.</p></body></html>
+
Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===================================================================
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-11-15 01:53:16 UTC (rev 319223)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-11-15 03:15:19 UTC (rev 319224)
@@ -1815,22 +1815,8 @@
static int php_cli_server_dispatch_script(php_cli_server *server, php_cli_server_client *client TSRMLS_DC) /* {{{ */
{
- php_cli_server_client_populate_request_info(client, &SG(request_info));
- {
- char **auth;
- if (SUCCESS == zend_hash_find(&client->request.headers, "Authorization", sizeof("Authorization"), (void**)&auth)) {
- php_handle_auth_data(*auth TSRMLS_CC);
- }
- }
- SG(sapi_headers).http_response_code = 200;
- if (FAILURE == php_request_startup(TSRMLS_C)) {
- /* should never be happen */
- destroy_request_info(&SG(request_info));
- return FAILURE;
- }
if (strlen(client->request.path_translated) != client->request.path_translated_len) {
/* can't handle paths that contain nul bytes */
- destroy_request_info(&SG(request_info));
return php_cli_server_send_error_page(server, client, 400 TSRMLS_CC);
}
{
@@ -1846,9 +1832,6 @@
}
php_cli_server_log_response(client, SG(sapi_headers).http_response_code, NULL TSRMLS_CC);
- php_request_shutdown(0);
- php_cli_server_close_connection(server, client TSRMLS_CC);
- destroy_request_info(&SG(request_info));
return SUCCESS;
} /* }}} */
@@ -1910,27 +1893,35 @@
}
/* }}} */
-static int php_cli_server_dispatch_router(php_cli_server *server, php_cli_server_client *client TSRMLS_DC) /* {{{ */
-{
- int decline = 0;
-
- if (!server->router) {
- return 1;
- }
-
+static int php_cli_server_request_startup(php_cli_server *server, php_cli_server_client *client TSRMLS_DC) { /* {{{ */
+ char **auth;
php_cli_server_client_populate_request_info(client, &SG(request_info));
- {
- char **auth;
- if (SUCCESS == zend_hash_find(&client->request.headers, "Authorization", sizeof("Authorization"), (void**)&auth)) {
- php_handle_auth_data(*auth TSRMLS_CC);
- }
+ if (SUCCESS == zend_hash_find(&client->request.headers, "Authorization", sizeof("Authorization"), (void**)&auth)) {
+ php_handle_auth_data(*auth TSRMLS_CC);
}
SG(sapi_headers).http_response_code = 200;
if (FAILURE == php_request_startup(TSRMLS_C)) {
/* should never be happen */
destroy_request_info(&SG(request_info));
- return -1;
+ return FAILURE;
}
+
+ return SUCCESS;
+}
+/* }}} */
+
+static int php_cli_server_request_shutdown(php_cli_server *server, php_cli_server_client *client TSRMLS_DC) { /* {{{ */
+ php_request_shutdown(0);
+ php_cli_server_close_connection(server, client TSRMLS_CC);
+ destroy_request_info(&SG(request_info));
+ SG(server_context) = NULL;
+ return SUCCESS;
+}
+/* }}} */
+
+static int php_cli_server_dispatch_router(php_cli_server *server, php_cli_server_client *client TSRMLS_DC) /* {{{ */
+{
+ int decline = 0;
if (!php_handle_special_queries(TSRMLS_C)) {
zend_file_handle zfd;
char *old_cwd;
@@ -1965,45 +1956,52 @@
free_alloca(old_cwd, use_heap);
}
- if (decline) {
- php_request_shutdown_for_hook(0);
- } else {
- php_request_shutdown(0);
- php_cli_server_close_connection(server, client TSRMLS_CC);
- }
- destroy_request_info(&SG(request_info));
-
- return decline ? 1: 0;
+ return decline;
}
/* }}} */
static int php_cli_server_dispatch(php_cli_server *server, php_cli_server_client *client TSRMLS_DC) /* {{{ */
{
- int status;
+ int is_static_file = 0;
SG(server_context) = client;
- status = php_cli_server_dispatch_router(server, client TSRMLS_CC);
+ if (client->request.ext_len != 3 || memcmp(client->request.ext, "php", 3) || !client->request.path_translated) {
+ is_static_file = 1;
+ }
- if (status < 0) {
- goto fail;
- } else if (status > 0) {
- if (client->request.ext_len == 3 && memcmp(client->request.ext, "php", 3) == 0 && client->request.path_translated) {
- if (SUCCESS != php_cli_server_dispatch_script(server, client TSRMLS_CC) &&
- SUCCESS != php_cli_server_send_error_page(server, client, 500 TSRMLS_CC)) {
- goto fail;
- }
- } else {
- if (SUCCESS != php_cli_server_begin_send_static(server, client TSRMLS_CC)) {
- goto fail;
- }
+ if (server->router || !is_static_file) {
+ if (FAILURE == php_cli_server_request_startup(server, client TSRMLS_CC)) {
+ SG(server_context) = NULL;
+ php_cli_server_close_connection(server, client TSRMLS_CC);
+ destroy_request_info(&SG(request_info));
+ return SUCCESS;
}
+ }
+
+ if (server->router) {
+ if (!php_cli_server_dispatch_router(server, client TSRMLS_CC)) {
+ php_cli_server_request_shutdown(server, client TSRMLS_CC);
+ return SUCCESS;
+ }
}
- SG(server_context) = 0;
+
+ if (!is_static_file) {
+ if (SUCCESS == php_cli_server_dispatch_script(server, client TSRMLS_CC)
+ || SUCCESS != php_cli_server_send_error_page(server, client, 500 TSRMLS_CC)) {
+ php_cli_server_request_shutdown(server, client TSRMLS_CC);
+ return SUCCESS;
+ }
+ } else {
+ if (SUCCESS != php_cli_server_begin_send_static(server, client TSRMLS_CC)) {
+ php_cli_server_close_connection(server, client TSRMLS_CC);
+ }
+ SG(server_context) = NULL;
+ return SUCCESS;
+ }
+
+ SG(server_context) = NULL;
+ destroy_request_info(&SG(request_info));
return SUCCESS;
-fail:
- SG(server_context) = 0;
- php_cli_server_close_connection(server, client TSRMLS_CC);
- return SUCCESS;
}
/* }}} */
Modified: php/php-src/trunk/sapi/cli/tests/php_cli_server.inc
===================================================================
--- php/php-src/trunk/sapi/cli/tests/php_cli_server.inc 2011-11-15 01:53:16 UTC (rev 319223)
+++ php/php-src/trunk/sapi/cli/tests/php_cli_server.inc 2011-11-15 03:15:19 UTC (rev 319224)
@@ -5,7 +5,9 @@
$php_executable = getenv('TEST_PHP_EXECUTABLE');
$doc_root = __DIR__;
$router = "index.php";
- file_put_contents($doc_root . '/' . $router, '<?php ' . $code . ' ?>');
+ if ($code) {
+ file_put_contents($doc_root . '/' . $router, '<?php ' . $code . ' ?>');
+ }
$descriptorspec = array(
0 => STDIN,
Added: php/php-src/trunk/sapi/cli/tests/php_cli_server_012.phpt
===================================================================
--- php/php-src/trunk/sapi/cli/tests/php_cli_server_012.phpt (rev 0)
+++ php/php-src/trunk/sapi/cli/tests/php_cli_server_012.phpt 2011-11-15 03:15:19 UTC (rev 319224)
@@ -0,0 +1,55 @@
+--TEST--
+Bug #60159 (Router returns false, but POST is not passed to requested resource)
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+include "php_cli_server.inc";
+php_cli_server_start('print_r($_REQUEST); $_REQUEST["foo"] = "bar"; return FALSE;');
+$doc_root = __DIR__;
+file_put_contents($doc_root . '/request.php', '<?php print_r($_REQUEST); ?>');
+
+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 /request.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);
+@unlink($doc_root . '/request.php');
+
+?>
+--EXPECTF--
+HTTP/1.1 200 OK
+Host: %s
+Connection: closed
+X-Powered-By: PHP/%s
+Content-type: text/html
+
+Array
+(
+ [a] => b
+)
+Array
+(
+ [a] => b
+ [foo] => bar
+)
Added: php/php-src/trunk/sapi/cli/tests/php_cli_server_013.phpt
===================================================================
--- php/php-src/trunk/sapi/cli/tests/php_cli_server_013.phpt (rev 0)
+++ php/php-src/trunk/sapi/cli/tests/php_cli_server_013.phpt 2011-11-15 03:15:19 UTC (rev 319224)
@@ -0,0 +1,108 @@
+--TEST--
+No router, no script
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+include "php_cli_server.inc";
+php_cli_server_start(NULL, TRUE);
+
+list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
+$port = intval($port)?:80;
+$output = '';
+
+$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
+if (!$fp) {
+ die("connect failed");
+}
+
+
+if(fwrite($fp, <<<HEADER
+POST / HTTP/1.1
+Host: {$host}
+Content-Type: application/x-www-form-urlencoded
+Content-Length: 3
+
+a=b
+HEADER
+)) {
+ while (!feof($fp)) {
+ $output .= fgets($fp);
+ }
+}
+
+echo preg_replace("/<style type=\"text\/css\">(.*?)<\/style>/s", "<style type=\"text/css\">AAA</style>", $output), "\n";
+fclose($fp);
+
+
+$output = '';
+$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
+if (!$fp) {
+ die("connect failed");
+}
+
+if(fwrite($fp, <<<HEADER
+GET /main/style.css HTTP/1.1
+Host: {$host}
+
+
+HEADER
+)) {
+ while (!feof($fp)) {
+ $output .= fgets($fp);
+ }
+}
+
+echo preg_replace("/<style type=\"text\/css\">(.*?)<\/style>/s", "<style type=\"text/css\">AAA</style>", $output), "\n";
+fclose($fp);
+
+$output = '';
+$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
+if (!$fp) {
+ die("connect failed");
+}
+
+if(fwrite($fp, <<<HEADER
+HEAD /main/foo/bar HTTP/1.1
+Host: {$host}
+
+
+HEADER
+)) {
+ while (!feof($fp)) {
+ $output .= fgets($fp);
+ }
+}
+
+echo preg_replace("/<style type=\"text\/css\">(.*?)<\/style>/s", "<style type=\"text/css\">AAA</style>", $output), "\n";
+fclose($fp);
+?>
+--EXPECTF--
+
+HTTP/1.1 404 Not Found
+Host: %s
+Connection: closed
+Content-Type: text/html; charset=UTF-8
+Content-Length: %d
+
+<html><head><title>404 Not Found</title><style type="text/css">AAA</style>
+</head><body><h1 class="h">Not Found</h1><p>The requested resource / was not found on this server.</p></body></html>
+HTTP/1.1 404 Not Found
+Host: %s
+Connection: closed
+Content-Type: text/html; charset=UTF-8
+Content-Length: %d
+
+<html><head><title>404 Not Found</title><style type="text/css">AAA</style>
+</head><body><h1 class="h">Not Found</h1><p>The requested resource /main/style.css was not found on this server.</p></body></html>
+HTTP/1.1 404 Not Found
+Host: %s
+Connection: closed
+Content-Type: text/html; charset=UTF-8
+Content-Length: %d
+
+<html><head><title>404 Not Found</title><style type="text/css">AAA</style>
+</head><body><h1 class="h">Not Found</h1><p>The requested resource /main/foo/bar was not found on this server.</p></body></html>
+
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php