Annotation of embedaddon/php/sapi/cli/tests/php_cli_server_005.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Post a file
! 3: --SKIPIF--
! 4: <?php
! 5: include "skipif.inc";
! 6: ?>
! 7: --FILE--
! 8: <?php
! 9: include "php_cli_server.inc";
! 10: php_cli_server_start('var_dump($_FILES);');
! 11:
! 12: list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
! 13: $port = intval($port)?:80;
! 14:
! 15: $fp = fsockopen($host, $port, $errno, $errstr, 0.5);
! 16: if (!$fp) {
! 17: die("connect failed");
! 18: }
! 19:
! 20: $post_data = <<<POST
! 21: -----------------------------114782935826962
! 22: Content-Disposition: form-data; name="userfile"; filename="laruence.txt"
! 23: Content-Type: text/plain
! 24:
! 25: I am not sure about this.
! 26:
! 27: -----------------------------114782935826962--
! 28:
! 29:
! 30: POST;
! 31:
! 32: $post_len = strlen($post_data);
! 33:
! 34: if(fwrite($fp, <<<HEADER
! 35: POST / HTTP/1.1
! 36: Host: {$host}
! 37: Content-Type: multipart/form-data; boundary=---------------------------114782935826962
! 38: Content-Length: {$post_len}
! 39:
! 40:
! 41: {$post_data}
! 42: HEADER
! 43: )) {
! 44: while (!feof($fp)) {
! 45: echo fgets($fp);
! 46: }
! 47: }
! 48:
! 49: ?>
! 50: --EXPECTF--
! 51: HTTP/1.1 200 OK
! 52: Host: %s
! 53: Connection: close
! 54: X-Powered-By: PHP/%s
! 55: Content-type: text/html
! 56:
! 57: array(1) {
! 58: ["userfile"]=>
! 59: array(5) {
! 60: ["name"]=>
! 61: string(12) "laruence.txt"
! 62: ["type"]=>
! 63: string(10) "text/plain"
! 64: ["tmp_name"]=>
! 65: string(%d) "%s"
! 66: ["error"]=>
! 67: int(0)
! 68: ["size"]=>
! 69: int(26)
! 70: }
! 71: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>