1--TEST-- 2Bug #60477: Segfault after two multipart/form-data POST requestes 3--SKIPIF-- 4<?php 5include "skipif.inc"; 6?> 7--FILE-- 8<?php 9include "php_cli_server.inc"; 10php_cli_server_start('echo done, "\n";', null); 11 12list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); 13$port = intval($port)?:80; 14$output = ''; 15 16// note: select() on Windows (& some other platforms) has historical issues with 17// timeouts less than 1000 millis(0.5). it may be better to increase these 18// timeouts to 1000 millis(1.0) (fsockopen eventually calls select()). 19// see articles like: http://support.microsoft.com/kb/257821 20$fp = fsockopen($host, $port, $errno, $errstr, 0.5); 21if (!$fp) { 22 die("connect failed"); 23} 24 25if(fwrite($fp, <<<HEADER 26POST /index.php HTTP/1.1 27Host: {$host} 28Content-Type: multipart/form-data; boundary=---------123456789 29Content-Length: 70 30 31---------123456789 32Content-Type: application/x-www-form-urlencoded 33a=b 34HEADER 35)) { 36 while (!feof($fp)) { 37 $output .= fgets($fp); 38 } 39} 40 41fclose($fp); 42 43$fp = fsockopen($host, $port, $errno, $errstr, 0.5); 44if(fwrite($fp, <<<HEADER 45POST /main/no-exists.php HTTP/1.1 46Host: {$host} 47Content-Type: multipart/form-data; boundary=---------123456789 48Content-Length: 70 49 50---------123456789 51Content-Type: application/x-www-form-urlencoded 52a=b 53HEADER 54)) { 55 while (!feof($fp)) { 56 $output .= fgets($fp); 57 } 58} 59 60echo preg_replace("/<style>(.*?)<\/style>/s", "<style>AAA</style>", $output), "\n"; 61fclose($fp); 62 63?> 64--EXPECTF-- 65HTTP/1.1 200 OK 66Host: %s 67Date: %s 68Connection: close 69X-Powered-By: %s 70Content-type: %s 71 72done 73HTTP/1.1 404 Not Found 74Host: %s 75Date: %s 76Connection: close 77Content-Type: %s 78Content-Length: %d 79 80<!doctype html><html><head><title>404 Not Found</title><style>AAA</style> 81</head><body><h1>Not Found</h1><p>The requested resource <code class="url">/main/no-exists.php</code> was not found on this server.</p></body></html> 82