File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / sapi / cli / tests / php_cli_server_009.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:34:35 2012 UTC (12 years, 2 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, HEAD
php 5.4.3+patches

    1: --TEST--
    2: PATH_INFO (relevant to #60112)
    3: --DESCRIPTION--
    4: After this fix(#60112), previously 404 request like "localhost/foo/bar"
    5: now could serve correctly with request_uri "index.php" and PATH_INFO "/foo/bar/"
    6: --SKIPIF--
    7: <?php
    8: include "skipif.inc"; 
    9: ?>
   10: --FILE--
   11: <?php
   12: include "php_cli_server.inc";
   13: php_cli_server_start('var_dump($_SERVER["PATH_INFO"]);', TRUE);
   14: 
   15: list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
   16: $port = intval($port)?:80;
   17: 
   18: $fp = fsockopen($host, $port, $errno, $errstr, 0.5);
   19: if (!$fp) {
   20:   die("connect failed");
   21: }
   22: 
   23: if(fwrite($fp, <<<HEADER
   24: GET /foo/bar HTTP/1.1
   25: Host: {$host}
   26: 
   27: 
   28: HEADER
   29: )) {
   30: 	while (!feof($fp)) {
   31: 		echo fgets($fp);
   32: 	}
   33: }
   34: 
   35: fclose($fp);
   36: 
   37: $fp = fsockopen($host, $port, $errno, $errstr, 0.5);
   38: if (!$fp) {
   39:   die("connect failed");
   40: }
   41: 
   42: 
   43: if(fwrite($fp, <<<HEADER
   44: GET /foo/bar/ HTTP/1.0
   45: Host: {$host}
   46: 
   47: 
   48: HEADER
   49: )) {
   50: 	while (!feof($fp)) {
   51: 		echo fgets($fp);
   52: 	}
   53: }
   54: 
   55: fclose($fp);
   56: 
   57: $fp = fsockopen($host, $port, $errno, $errstr, 0.5);
   58: if (!$fp) {
   59:   die("connect failed");
   60: }
   61: 
   62: 
   63: if(fwrite($fp, <<<HEADER
   64: GET /foo/bar.js HTTP/1.0
   65: Host: {$host}
   66: 
   67: 
   68: HEADER
   69: )) {
   70: 	while (!feof($fp)) {
   71: 		echo fgets($fp);
   72: 		break;
   73: 	}
   74: }
   75: 
   76: fclose($fp);
   77: ?>
   78: --EXPECTF--
   79: HTTP/1.1 200 OK
   80: Host: %s
   81: Connection: close
   82: X-Powered-By: PHP/%s
   83: Content-type: text/html
   84: 
   85: string(8) "/foo/bar"
   86: HTTP/1.0 200 OK
   87: Host: %s
   88: Connection: close
   89: X-Powered-By: PHP/%s
   90: Content-type: text/html
   91: 
   92: string(9) "/foo/bar/"
   93: HTTP/1.0 404 Not Found

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>