1: --TEST--
2: Bug #60477: Segfault after two multipart/form-data POST requestes
3: --SKIPIF--
4: <?php
5: include "skipif.inc";
6: ?>
7: --FILE--
8: <?php
9: include "php_cli_server.inc";
10: php_cli_server_start('echo done, "\n";', TRUE);
11:
12: list($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);
21: if (!$fp) {
22: die("connect failed");
23: }
24:
25: if(fwrite($fp, <<<HEADER
26: POST /index.php HTTP/1.1
27: Host: {$host}
28: Content-Type: multipart/form-data; boundary=---------123456789
29: Content-Length: 70
30:
31: ---------123456789
32: Content-Type: application/x-www-form-urlencoded
33: a=b
34: HEADER
35: )) {
36: while (!feof($fp)) {
37: $output .= fgets($fp);
38: }
39: }
40:
41: fclose($fp);
42:
43: $fp = fsockopen($host, $port, $errno, $errstr, 0.5);
44: if(fwrite($fp, <<<HEADER
45: POST /main/no-exists.php HTTP/1.1
46: Host: {$host}
47: Content-Type: multipart/form-data; boundary=---------123456789
48: Content-Length: 70
49:
50: ---------123456789
51: Content-Type: application/x-www-form-urlencoded
52: a=b
53: HEADER
54: )) {
55: while (!feof($fp)) {
56: $output .= fgets($fp);
57: }
58: }
59:
60: echo preg_replace("/<style>(.*?)<\/style>/s", "<style>AAA</style>", $output), "\n";
61: fclose($fp);
62:
63: ?>
64: --EXPECTF--
65:
66: HTTP/1.1 200 OK
67: Host: %s
68: Connection: close
69: X-Powered-By: %s
70: Content-type: %s
71:
72: done
73: HTTP/1.1 404 Not Found
74: Host: %s
75: Connection: close
76: Content-Type: %s
77: Content-Length: %d
78:
79: <!doctype html><html><head><title>404 Not Found</title><style>AAA</style>
80: </head><body><h1>Not Found</h1><p>The requested resource /main/no-exists.php was not found on this server.</p></body></html>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>