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

Ensure PSR-7 stream read() is called with an int argument per spec #2543

Merged
merged 1 commit into from Nov 27, 2018
Merged

Ensure PSR-7 stream read() is called with an int argument per spec #2543

merged 1 commit into from Nov 27, 2018

Conversation

soren121
Copy link

@soren121 soren121 commented Nov 22, 2018

This fixes #2511.

The PSR-7 spec requires that the length argument of the stream read method be an integer, but Slim retrieves the content length as a string due to its use of $response->getHeaderLine. This causes compatibility issues with PSR-7 implementations that use strict typing, namely zendframework/zend-diactoros 2.0+.

I'm not sure how to write a unit test for this change as it's a type change that doesn't affect output/behavior except with strict PSR-7 implementations.

The spec requires that the length argument of the body read method be
an integer, but Slim's implementation causes Content-Length to be
retrieved as a string due to its use of $response->getHeaderLine. This
causes compatibility issues with PSR-7 implementations that use strict
typing, namely zendframework/zend-dictoros 2.0+.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.814% when pulling 52f23a9 on soren121:psr7-body-read-int into 25da5eb on slimphp:3.x.

@soren121 soren121 changed the title Ensure PSR-7 body->read() is called with an int argument per spec Ensure PSR-7 stream read() is called with an int argument per spec Nov 22, 2018
@akrabat akrabat added this to the 3.12 milestone Nov 27, 2018
@akrabat akrabat added the Slim 3 label Nov 27, 2018
@akrabat akrabat merged commit 52f23a9 into slimphp:3.x Nov 27, 2018
akrabat added a commit that referenced this pull request Nov 27, 2018
@akrabat
Copy link
Member

akrabat commented Nov 27, 2018

Thank you for this. Good catch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stream Read TypeError
3 participants