Skip to content

Fix binary files being truncated when cached #197

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Conversation

vojtagrec
Copy link

@vojtagrec vojtagrec commented Apr 15, 2025

When the cached Guzzle response is unserialized, the request/response stream is passed through PumpStream. The problem is that PumpStream uses plain strlen() to measure data "pumped" into the buffer (which is logically correct IMHO), whereas BodyStore and CacheEntry use mb_ functions.

This works just fine for "normal" (non-multibyte) text streams but breaks horribly in case of binary data (images etc.). The mb_strlen() counts some bytes as multibyte characters, returning smaller size, effectively causing the file being truncated when it's cached...

Fixes #196

When the cached Guzzle response is unserialized, the request/response
stream is passed through PumpStream. The problem is that PumpStream uses
plain `strlen()` to measure data "pumped" into the buffer (which is
logically correct IMHO), whereas BodyStore and CacheEntry use `mb_`
functions.

This works just fine for "normal" (non-multibyte) text streams but
breaks horribly in case of binart data (images etc.). The `mb_strlen()`
counts some bytes as multibyte characters, returning smaller size,
effectively causing the file being truncated when it's cached...

Fixes Kevinrob#196
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Binary files truncated when cached
1 participant