Fix response body retrieval in combination with logging (#106)
Fix response body retrieval in combination with logging (#106)

All HTTP responses are empty when configuring HTTP request logging by
creating a GuzzleHttp\HandlerStack,
adding a logger created by \GuzzleHttp\Middleware::log()
and setting the stack in the "handler" extra option in GuzzleHttpProvider.

Guzzle's $result->getBody() returns a StreamInterface, and its
getContents() method docs says:
> Returns the remaining contents in a string

Since the logger in the handler stack already accessed the
response body, getContents() returns an empty string.

The correct way to access the full response body is using the
__toString() method, which is invoked by casting it to a string.

This patch correctly casts the response body stream to a string
instead of using getContents().

More information:
- https://github.com/guzzle/guzzle/pull/1262
  rewind the stream after logging #1262
- https://michaelstivala.com/logging-guzzle-requests/
  "A short note on working with Guzzle responses"
saintsystems/odata-client-php