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

Update Message.php #71

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function getBodyAsString() : string {
return ob_get_clean();
}
$contentLength = $this->getHeader('Content-Length');
if (null === $contentLength) {
if (null === $contentLength || empty($contentLength)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is less error-prone to set $contentLength to 0 if empty. The bug could appear somewhere else later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 is not the same as not specifying the parameter. In this case we stream the whole body if no $contentLength was expected. Setting to to 0 would mess this up.

@sash04ek this has still an issue though, because empty() returns true for 0, which is definitely not what we want.

return stream_get_contents($body);
} else {
return stream_get_contents($body, (int)$contentLength);
Expand Down