Skip to content

Commit 2b04d12

Browse files
committed
[http parser] add http version
1 parent 951622a commit 2b04d12

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

php_uv.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6376,10 +6376,11 @@ PHP_FUNCTION(uv_http_parser_init)
63766376
*/
63776377
PHP_FUNCTION(uv_http_parser_execute)
63786378
{
6379-
zval *z_parser,*result, *headers = NULL;
6379+
zval *z_parser = NULL, *result = NULL, *version = NULL, *headers = NULL;
63806380
php_http_parser_context *context;
63816381
char *body;
63826382
int body_len;
6383+
char version_buffer[4] = {0};
63836384
size_t nparsed = 0;
63846385

63856386
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
@@ -6414,8 +6415,13 @@ PHP_FUNCTION(uv_http_parser_execute)
64146415
}
64156416
add_assoc_long(result, "UPGRADE", (long)context->parser.upgrade);
64166417

6418+
MAKE_STD_ZVAL(version);
6419+
snprintf(version_buffer, 4, "%d.%d", context->parser.http_major, context->parser.http_minor);
6420+
ZVAL_STRING(version, version_buffer, 1);
6421+
64176422
MAKE_STD_ZVAL(headers);
64186423
ZVAL_ZVAL(headers, context->headers, 1, 0);
6424+
add_assoc_zval(headers, "VERSION", version);
64196425
add_assoc_zval(result, "HEADERS", headers);
64206426

64216427
if (context->finished == 1) {

0 commit comments

Comments
 (0)