chobie / php-uv

libuv php extension
184 stars 21 forks source link

Notice: uv_http_parser_execute(): passed uv_parser resource has already finished. #42

Open gplanchat opened 11 years ago

gplanchat commented 11 years ago

While I am using the example inthe docs for uv_http_parser_init and uv_http_parser_execute (https://github.com/chobie/php-uv#example-102), with a POST request, I have in some cases a warning and the parsing fails :

Notice: uv_http_parser_execute(): passed uv_parser resource has already finished. in D:\php-env\workspace\php-io\src\test_http_parser.php on line 25

When I execute 10 times the example, the first 2 times works well, the following times it fails :

<?php

for ($i = 0; $i < 10; $i++) {
    $parser = uv_http_parser_init(UV::HTTP_REQUEST);
    $result = [];

    $request = <<<REQUEST_EOF
POST /img/http-parser.png?key=value#frag HTTP/1.1
Host: chobie.net
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20100101 Firefox/12.0
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Referer: http://chobie.net/
Cookie: key=value
Cache-Control: max-age=0
Content-Type: application/x-www-form-urlencoded
Content-Length: 50

licenseID=string&content=string&/paramsXML=string

REQUEST_EOF;

    if (uv_http_parser_execute($parser, $request, $result)) {
        var_dump($result);
    }
}

I am using Windows builds from http://windows.php.net/downloads/pecl/snaps/uv/0.0.1/, with PHP as CLI :

$ php -v
PHP 5.4.11 (cli) (built: Jan 16 2013 20:26:43)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

$ php -i
phpinfo()
PHP Version => 5.4.11

System => Windows NT GREG-PC 6.0 build 6002 (Windows Vista Ultimate Edition Service Pack 2) i586
Build Date => Jan 16 2013 20:22:58
Compiler => MSVC9 (Visual C++ 2008)
Architecture => x86
Configure Command => cscript /nologo configure.js  "--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=C:\php-s
Server API => Command Line Interface
Virtual Directory Support => enabled
Configuration File (php.ini) Path => C:\Windows
Loaded Configuration File => C:\Program Files (x86)\PHP\php-5.4\php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
PHP API => 20100412
PHP Extension => 20100525
Zend Extension => 220100525
Zend Extension Build => API220100525,TS,VC9
PHP Extension Build => API20100525,TS,VC9
Debug Build => no
Thread Safety => enabled
Zend Signal Handling => disabled
Zend Memory Manager => enabled
Zend Multibyte Support => provided by mbstring
IPv6 Support => enabled
DTrace Support => disabled

Registered PHP Streams => php, file, glob, data, http, ftp, zip, compress.zlib, compress.bzip2, https, ftps, phar
Registered Stream Socket Transports => tcp, udp, ssl, sslv3, sslv2, tls
Registered Stream Filters => convert.iconv.*, mcrypt.*, mdecrypt.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, zlib.*, bzip2.*

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

uv
PHP libuv Extension

libuv Support => enabled
Version => 0.0.1
bundled libuv Version => 0.9
bundled http-parser Version => 1.0