-
Notifications
You must be signed in to change notification settings - Fork 59
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
Conversation
Fixed "stream_get_contents() expects parameter 2 to be long, string given" when in server request 'Content-Length' is an empty string.
@@ -81,7 +81,7 @@ function getBodyAsString() : string { | |||
return ob_get_clean(); | |||
} | |||
$contentLength = $this->getHeader('Content-Length'); | |||
if (null === $contentLength) { | |||
if (null === $contentLength || empty($contentLength)) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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.
This can now be closed as the issue has been fixed by #73 |
Fixed "stream_get_contents() expects parameter 2 to be long, string given" when in server request 'Content-Length' is an empty string.