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

Update Message.php #71

wants to merge 1 commit into from

Conversation

sash04ek
Copy link

@sash04ek sash04ek commented Nov 7, 2016

Fixed "stream_get_contents() expects parameter 2 to be long, string given" when in server request 'Content-Length' is an empty string.

Fixed "stream_get_contents() expects parameter 2 to be long, string given" when in server request 'Content-Length' is an empty string.
Hywan
Hywan previously requested changes Nov 7, 2016
@@ -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.

@@ -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.

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.

@evert evert dismissed Hywan’s stale review November 8, 2016 14:33

incorrect suggestion

@petrkotek
Copy link
Contributor

This can now be closed as the issue has been fixed by #73

@evert evert closed this Jan 3, 2017
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.

4 participants