Coder Social home page Coder Social logo

Comments (5)

kanariezwart avatar kanariezwart commented on May 10, 2024

I couldn't find the actual problem but I think the bug is located when calling the
GuzzleHttp\Message\Response through the subscribed guzzle client.

v 2.1.0: php $response->getBody()->getContents(); // returns the content as string
v 2.2.0: php $response->getBody()->getContents(); // returns empty string ''

When the response body is cast to string all works again.

(string)$response->getBody()

Got any ideas?

from guzzle-oauth2-plugin.

pjcdawkins avatar pjcdawkins commented on May 10, 2024

It probably means that the body has been read before somewhere. It's a stream:

$body = $response->getBody();

$body->getContents(); // string, on the first call
$body->getContents(); // empty string on subsequent calls

$body->seek(0);
$body->getContents(); // string again

from guzzle-oauth2-plugin.

kanariezwart avatar kanariezwart commented on May 10, 2024

@pjcdawkins Should I try to rewind my getContents() before calling getContents()?
I don't think the body has been read before. Unless Guzzle (now) does some magic I'm still unaware of. I'll try to report back something useful asap.

from guzzle-oauth2-plugin.

pjcdawkins avatar pjcdawkins commented on May 10, 2024

Yes, rewind the body with $body->seek(0), before getContents(), and see if that makes a difference

from guzzle-oauth2-plugin.

kanariezwart avatar kanariezwart commented on May 10, 2024

It works! Thanks.

from guzzle-oauth2-plugin.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.