File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / sapi / cli / tests / php_cli_server_013.phpt
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Mon Jul 22 01:32:13 2013 UTC (11 years ago) by misho
Branches: php, MAIN
CVS tags: v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17, HEAD
5.4.17

    1: --TEST--
    2: No router, no script
    3: --SKIPIF--
    4: <?php
    5: include "skipif.inc"; 
    6: ?>
    7: --FILE--
    8: <?php
    9: include "php_cli_server.inc";
   10: php_cli_server_start(NULL, TRUE);
   11: 
   12: list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
   13: $port = intval($port)?:80;
   14: $output = '';
   15: 
   16: $fp = fsockopen($host, $port, $errno, $errstr, 0.5);
   17: if (!$fp) {
   18:   die("connect failed");
   19: }
   20: 
   21: 
   22: if(fwrite($fp, <<<HEADER
   23: POST / HTTP/1.1
   24: Host: {$host}
   25: Content-Type: application/x-www-form-urlencoded
   26: Content-Length: 3
   27: 
   28: a=b
   29: HEADER
   30: )) {
   31: 	while (!feof($fp)) {
   32: 		$output .= fgets($fp);
   33: 	}
   34: }
   35: 
   36: echo preg_replace("/<style>(.*?)<\/style>/s", "<style>AAA</style>", $output), "\n";
   37: fclose($fp);
   38: 
   39: 
   40: $output = '';
   41: $fp = fsockopen($host, $port, $errno, $errstr, 0.5);
   42: if (!$fp) {
   43:   die("connect failed");
   44: }
   45: 
   46: if(fwrite($fp, <<<HEADER
   47: GET /main/style.css HTTP/1.1
   48: Host: {$host}
   49: 
   50: 
   51: HEADER
   52: )) {
   53: 	while (!feof($fp)) {
   54: 		$output .= fgets($fp);
   55: 	}
   56: }
   57: 
   58: echo preg_replace("/<style>(.*?)<\/style>/s", "<style>AAA</style>", $output), "\n";
   59: fclose($fp);
   60: 
   61: $output = '';
   62: $fp = fsockopen($host, $port, $errno, $errstr, 0.5);
   63: if (!$fp) {
   64:   die("connect failed");
   65: }
   66: 
   67: if(fwrite($fp, <<<HEADER
   68: HEAD /main/foo/bar HTTP/1.1
   69: Host: {$host}
   70: 
   71: 
   72: HEADER
   73: )) {
   74: 	while (!feof($fp)) {
   75: 		$output .= fgets($fp);
   76: 	}
   77: }
   78: 
   79: echo preg_replace("/<style>(.*?)<\/style>/s", "<style>AAA</style>", $output), "\n";
   80: fclose($fp);
   81: ?>
   82: --EXPECTF--
   83: 
   84: HTTP/1.1 404 Not Found
   85: Host: %s
   86: Connection: close
   87: Content-Type: text/html; charset=UTF-8
   88: Content-Length: %d
   89: 
   90: <!doctype html><html><head><title>404 Not Found</title><style>AAA</style>
   91: </head><body><h1>Not Found</h1><p>The requested resource / was not found on this server.</p></body></html>
   92: HTTP/1.1 404 Not Found
   93: Host: %s
   94: Connection: close
   95: Content-Type: text/html; charset=UTF-8
   96: Content-Length: %d
   97: 
   98: <!doctype html><html><head><title>404 Not Found</title><style>AAA</style>
   99: </head><body><h1>Not Found</h1><p>The requested resource /main/style.css was not found on this server.</p></body></html>
  100: HTTP/1.1 404 Not Found
  101: Host: %s
  102: Connection: close
  103: Content-Type: text/html; charset=UTF-8
  104: Content-Length: %d
  105: 
  106: <!doctype html><html><head><title>404 Not Found</title><style>AAA</style>
  107: </head><body><h1>Not Found</h1><p>The requested resource /main/foo/bar was not found on this server.</p></body></html>
  108: 

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