Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix Content retrieval in HttpTransport with custom HttpClient #343

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

Merged
merged 2 commits into from
Apr 8, 2025

Conversation

martinhoch42
Copy link
Contributor

@martinhoch42 martinhoch42 commented Feb 27, 2024

getContent does not return the content of the body but the remaining content of the stream.

If you were to use OpenAI::factory with withHttpClient and, for example, a logging middleware, getContent would return an empty string since the stream was already read by the log middleware.

See:

https://www.php-fig.org/psr/psr-7/
https://stackoverflow.com/questions/30549226/guzzlehttp-how-get-the-body-of-a-response-from-guzzle-6

fixes: #432

getContent does not return the content of the body but the remaining
content of the body.

If you were to OpenAI::factory withHttpClient and i.e. a logging
middlewere getContent would return an empty string since the content was
already read by the log middleware.

See:

https://www.php-fig.org/psr/psr-7/
https://stackoverflow.com/questions/30549226/guzzlehttp-how-get-the-body-of-a-response-from-guzzle-6
@iBotPeaches
Copy link
Collaborator

@martinhoch42 - still around to rebase this? Looks like this will fix #432

@iBotPeaches iBotPeaches merged commit 023bd6b into openai-php:main Apr 8, 2025
20 checks passed
@iBotPeaches
Copy link
Collaborator

thanks!

@iBotPeaches iBotPeaches added the bug Something isn't working label Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Empty body in HttpTransporter::requestObject ($response->getBody()->getContents()) when using Guzzle client with Middleware::log()
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.