Closed vaidasm closed 9 years ago
hey @vaidasm thanks for the PR! Would you mind sharing a test case that was failing?
cheers!
Hi @odino, just added a simple testcase for this. $request->getBody()->getContents()
is getting executed when request is being sent and when called the second time getContents
returns empty string.
getContents
is reads stream from current position until the end. If we call it before sending request, position is 0, so this method returns all the body string. After guzzle send the request, position is not zero (its at the end of stream) - and so, getContents
returns empty string. The proper way of getting the entire body string is to cast body to string (or call __toString()
).
You can test this behaviour: just run this test against current master.
ah got it! then thanks man, we should merge it
This fixes the way stream contents is read. See: http://docs.guzzlephp.org/en/latest/streams.html#creating-streams