Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to validate "27C" as chunk length header #76

Closed
mdrost opened this issue Mar 18, 2017 · 4 comments
Closed

Unable to validate "27C" as chunk length header #76

mdrost opened this issue Mar 18, 2017 · 4 comments

Comments

@mdrost
Copy link
Contributor

mdrost commented Mar 18, 2017

I don't know how to reproduce problem using only this library, but with WyriHaximus/react-guzzle-psr7 this code

<?php

require_once __DIR__ . '/vendor/autoload.php';

$loop = React\EventLoop\Factory::create();
$handler = new WyriHaximus\React\GuzzlePsr7\HttpClientAdapter($loop);
$client = new GuzzleHttp\Client([
    'handler' => GuzzleHttp\HandlerStack::create($handler),
]);

$request = new GuzzleHttp\Psr7\Request('GET', 'https://wizzair.com/');
$promise = $client->sendAsync($request)->then(function (Psr\Http\Message\ResponseInterface $response) {
    echo (string)$response->getBody();
});

$promise->wait();

produces

PHP Fatal error:  Uncaught Exception: Unable to validate "27C" as chunk length header in /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/ChunkedStreamDecoder.php:122
Stack trace:
#0 /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/ChunkedStreamDecoder.php(70): React\HttpClient\ChunkedStreamDecoder->iterateBuffer()
#1 [internal function]: React\HttpClient\ChunkedStreamDecoder->handleData('="Original" src...', Object(React\Stream\Stream))
#2 /home/mateusz/git/react-guzzle-test/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(64): call_user_func_array(Array, Array)
#3 /home/mateusz/git/react-guzzle-test/vendor/react/stream/src/Stream.php(173): Evenement\EventEmitter->emit('data', Array)
#4 [internal function]: React\Stream\Stream->handleData(Resource id #96, Object(React\EventLoop\StreamSelectLoop))
#5 /home/mateusz/git/react-guzzle-test/vendor/react/event-loop/src/StreamSelectLoop.php(232): call_user_func(Array, Resource id #96, Object(React\EventLoop\StreamSelectLoop))
#6 /home/mat in /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/Request.php on line 150
@WyriHaximus
Copy link
Member

Hey thank you for reporting your issue. By the looks of it you're calling $promise->wait(); which forces the promise to resolve and blocks the loop. Running the loop the normal way, $loop->run(); will ensure the loop isn't blocked. I've just tried your URL with this example and had no issues what so ever: https://github.com/WyriHaximus/react-guzzle-psr7/blob/master/examples/basic.php

This should resolve your issue, so I'll close this for now. If you feel this problem persists, please report back and we can reopen this 👍

@mdrost
Copy link
Contributor Author

mdrost commented Mar 18, 2017

With other url's my code is not blocking.
When I change my code to

<?php

require_once __DIR__ . '/vendor/autoload.php';

$loop = React\EventLoop\Factory::create();
$handler = new WyriHaximus\React\GuzzlePsr7\HttpClientAdapter($loop);
$client = new GuzzleHttp\Client([
    'handler' => GuzzleHttp\HandlerStack::create($handler),
]);

$request = new GuzzleHttp\Psr7\Request('GET', 'https://wizzair.com/');
$promise = $client->sendAsync($request)->then(function (Psr\Http\Message\ResponseInterface $response) {
    echo (string)$response->getBody();
}, function (Exception $e) {
    echo $e;
});

$loop->run();

I get

Exception: Unable to validate "27C" as chunk length header in /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/ChunkedStreamDecoder.php:122
Stack trace:
#0 /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/ChunkedStreamDecoder.php(70): React\HttpClient\ChunkedStreamDecoder->iterateBuffer()
#1 [internal function]: React\HttpClient\ChunkedStreamDecoder->handleData('="Original" src...', Object(React\Stream\Stream))
#2 /home/mateusz/git/react-guzzle-test/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(64): call_user_func_array(Array, Array)
#3 /home/mateusz/git/react-guzzle-test/vendor/react/stream/src/Stream.php(173): Evenement\EventEmitter->emit('data', Array)
#4 [internal function]: React\Stream\Stream->handleData(Resource id #96, Object(React\EventLoop\StreamSelectLoop))
#5 /home/mateusz/git/react-guzzle-test/vendor/react/event-loop/src/StreamSelectLoop.php(232): call_user_func(Array, Resource id #96, Object(React\EventLoop\StreamSelectLoop))
#6 /home/mateusz/git/react-guzzle-test/vendor/react/event-loop/src/StreamSelectLoop.php(201): React\EventLoop\StreamSelectLoop->waitForStreamActivity(NULL)
#7 /home/mateusz/git/react-guzzle-test/test.php(18): React\EventLoop\StreamSelectLoop->run()
#8 {main}

Next RuntimeException: An error occurred in the underlying stream in /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/Response.php:90
Stack trace:
#0 [internal function]: React\HttpClient\Response->handleError(Object(Exception))
#1 /home/mateusz/git/react-guzzle-test/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(64): call_user_func_array(Array, Array)
#2 /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/ChunkedStreamDecoder.php(122): React\HttpClient\ChunkedStreamDecoder->emit('error', Array)
#3 /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/ChunkedStreamDecoder.php(70): React\HttpClient\ChunkedStreamDecoder->iterateBuffer()
#4 [internal function]: React\HttpClient\ChunkedStreamDecoder->handleData('="Original" src...', Object(React\Stream\Stream))
#5 /home/mateusz/git/react-guzzle-test/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(64): call_user_func_array(Array, Array)
#6 /home/mateusz/git/react-guzzle-test/vendor/react/stream/src/Stream.php(173): Evenement\EventEmitter->emit('data', Array)
#7 [internal function]: React\Stream\Stream->handleData(Resource id #96, Object(React\EventLoop\StreamSelectLoop))
#8 /home/mateusz/git/react-guzzle-test/vendor/react/event-loop/src/StreamSelectLoop.php(232): call_user_func(Array, Resource id #96, Object(React\EventLoop\StreamSelectLoop))
#9 /home/mateusz/git/react-guzzle-test/vendor/react/event-loop/src/StreamSelectLoop.php(201): React\EventLoop\StreamSelectLoop->waitForStreamActivity(NULL)
#10 /home/mateusz/git/react-guzzle-test/test.php(18): React\EventLoop\StreamSelectLoop->run()
#11 {main}

Next RuntimeException: An error occured in the response in /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/Request.php:150
Stack trace:
#0 [internal function]: React\HttpClient\Request->React\HttpClient\{closure}(Object(RuntimeException), Object(React\HttpClient\Response))
#1 /home/mateusz/git/react-guzzle-test/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(64): call_user_func_array(Object(Closure), Array)
#2 /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/Response.php(94): React\HttpClient\Response->emit('error', Array)
#3 [internal function]: React\HttpClient\Response->handleError(Object(Exception))
#4 /home/mateusz/git/react-guzzle-test/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(64): call_user_func_array(Array, Array)
#5 /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/ChunkedStreamDecoder.php(122): React\HttpClient\ChunkedStreamDecoder->emit('error', Array)
#6 /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/ChunkedStreamDecoder.php(70): React\HttpClient\ChunkedStreamDecoder->iterateBuffer()
#7 [internal function]: React\HttpClient\ChunkedStreamDecoder->handleData('="Original" src...', Object(React\Stream\Stream))
#8 /home/mateusz/git/react-guzzle-test/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(64): call_user_func_array(Array, Array)
#9 /home/mateusz/git/react-guzzle-test/vendor/react/stream/src/Stream.php(173): Evenement\EventEmitter->emit('data', Array)
#10 [internal function]: React\Stream\Stream->handleData(Resource id #96, Object(React\EventLoop\StreamSelectLoop))
#11 /home/mateusz/git/react-guzzle-test/vendor/react/event-loop/src/StreamSelectLoop.php(232): call_user_func(Array, Resource id #96, Object(React\EventLoop\StreamSelectLoop))
#12 /home/mateusz/git/react-guzzle-test/vendor/react/event-loop/src/StreamSelectLoop.php(201): React\EventLoop\StreamSelectLoop->waitForStreamActivity(NULL)
#13 /home/mateusz/git/react-guzzle-test/test.php(18): React\EventLoop\StreamSelectLoop->run()

Other url's works, just wizzair is somehow special.

@mdrost
Copy link
Contributor Author

mdrost commented Mar 18, 2017

Your example works fine until I change url to https://wizzair.com/ . Then i get An error occured in the response.

@mdrost
Copy link
Contributor Author

mdrost commented Mar 19, 2017

I fix that #77

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants