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 read response's body contents #95

Closed
SilverFire opened this issue Jun 6, 2016 · 7 comments
Closed

Unable to read response's body contents #95

SilverFire opened this issue Jun 6, 2016 · 7 comments

Comments

@SilverFire
Copy link

SilverFire commented Jun 6, 2016

Commit 45054d9#diff-f89246dce7e387482b2c6c584a5e7e9dR97 have introduced a bug by comparing $body with empty string.

I did not dug too deeply to find out the real reason of wrong behavior, but I guess it is caused by implicit calling of GuzzleHttp\Psr7\Stream::__toString() in order to cast object to string to make a comparison.

How to reproduce

        $client = new \GuzzleHttp\Client(['base_uri' => 'https://google.com.ua/']);
        $response = $client->request('GET');
        $html = $response->getBody()->getContents();

What is expected

$html contains a response HTML

What do we have instead

$html is an empty string

Patch?

Rolling back that line to if ($body !== null) fixes the problem. Not sure whether it is a proper fix.

Environment

PHP 5.6.20
Ubuntu 16.04
guzzle/psr7@dev-master

@SilverFire
Copy link
Author

Merging commit: 28d8dbf

@mtdowling
Copy link
Member

mtdowling commented Jun 6, 2016 via email

SilverFire referenced this issue Jun 7, 2016
- fixes an edge case and is more logical
- remove trimming of headers which is not according to psr-7
- fix '0' problem for response reason
- improve tests
@Tobion
Copy link
Member

Tobion commented Jun 7, 2016

I'm fixing this.

@GrahamCampbell
Copy link
Member

👍

@Tobion
Copy link
Member

Tobion commented Jun 7, 2016

See #96

@BenBezac
Copy link

BenBezac commented Jun 7, 2016

Was looking for a solution all the day and found this issue ;x

I rolled back to 1.3. and now i wait for the update ;)

@Tobion
Copy link
Member

Tobion commented Jun 7, 2016

I'm kinda surprised that so many developers seem to be relying on an unreleased, unstable version (dev-master). And for this library it doesn't even seem necessary as it is getting regular tags (unlike some other libraries where you might be forced to dev versions).

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

5 participants