php://input in CLI sapi
| From: | Timm Friebe | Date: | Sat, 03 Jan 2009 14:19:42 +0000 |
| Subject: | php://input in CLI sapi | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-42463@lists.php.net to get a copy of this message | ||
Hi,
is there any reason php://input is not supported in CLI sapi? It would be nice to test raw post data reading in unittests without having to run them inside a web server sapi and it's only a five-line patch making php://input read from stdin in cli (attached).
- Timm
Index: sapi/cli/php_cli.c =================================================================== RCS file: /repository/php-src/sapi/cli/php_cli.c,v retrieving revision 1.129.2.13.2.22.2.20 diff -u -r1.129.2.13.2.22.2.20 php_cli.c --- sapi/cli/php_cli.c 2 Jan 2009 13:14:49 -0000 1.129.2.13.2.22.2.20 +++ sapi/cli/php_cli.c 3 Jan 2009 14:15:56 -0000 @@ -346,6 +346,12 @@ } /* }}} */ +static int sapi_cli_read_post(char *buffer, uint count_bytes TSRMLS_DC) +{ + return read(0, buffer, count_bytes); +} +/* }}} */ + static int sapi_cli_header_handler(sapi_header_struct *h, sapi_header_op_enum op, sapi_headers_struct *s TSRMLS_DC) /* {{{ */ { return 0; @@ -414,7 +420,7 @@ sapi_cli_send_headers, /* send headers handler */ sapi_cli_send_header, /* send header handler */ - NULL, /* read POST data */ + sapi_cli_read_post, /* read POST data */ sapi_cli_read_cookies, /* read Cookies */ sapi_cli_register_variables, /* register server variables */
Index: sapi/cli/php_cli.c =================================================================== RCS file: /repository/php-src/sapi/cli/php_cli.c,v retrieving revision 1.129.2.13.2.22.2.20 diff -u -r1.129.2.13.2.22.2.20 php_cli.c --- sapi/cli/php_cli.c 2 Jan 2009 13:14:49 -0000 1.129.2.13.2.22.2.20 +++ sapi/cli/php_cli.c 3 Jan 2009 14:15:56 -0000 @@ -346,6 +346,12 @@ } /* }}} */ +static int sapi_cli_read_post(char *buffer, uint count_bytes TSRMLS_DC) +{ + return read(0, buffer, count_bytes); +} +/* }}} */ + static int sapi_cli_header_handler(sapi_header_struct *h, sapi_header_op_enum op, sapi_headers_struct *s TSRMLS_DC) /* {{{ */ { return 0; @@ -414,7 +420,7 @@ sapi_cli_send_headers, /* send headers handler */ sapi_cli_send_header, /* send header handler */ - NULL, /* read POST data */ + sapi_cli_read_post, /* read POST data */ sapi_cli_read_cookies, /* read Cookies */ sapi_cli_register_variables, /* register server variables */