Skip to content
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

Fix Content retrieval in HttpTransport with custom HttpClient #343

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

martinhoch42
Copy link

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

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants