Skip to content

Php 8 GuzzleHttp\Psr7\Stream::getContents stream is not getting the response content #1

@massimoconti

Description

@massimoconti

As stated in the title running the library with php 8.1 trigger an unexpected behavior with \GuzzleHttp\Psr7\Stream::getContents.
For instance in ContactApi::requestContactExportWithHttpInfo this code:

if ($returnType === '\SplFileObject') {
    $content = $responseBody; //stream goes to serializer
} else {
    **$content = $responseBody->getContents();**
    if ($returnType !== 'string') {
        $content = json_decode($content);
    }
}

return a $content = "".

I didn't go into details, but I found that might be a stream issue.
If I cast $responseBody into a string it works as expected since $content turn to be something like {"processId":90} thank to magic method GuzzleHttp\Psr7\Stream::__toString.

$content = (string) $responseBody;

Maybe it's a guzzle http issue, not a brevo php sdk issue.

Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions