Skip to content

Added support for multipart stream created from uri streams #27

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

Merged
merged 4 commits into from
Feb 14, 2017

Conversation

Mats
Copy link
Contributor

@Mats Mats commented Jan 16, 2017

Added support for multipart uri streams by ensuring content from non-seekable streams is not fetched using string casting.

Added testSupportURIResources phpUnit test validating the multipart stream created from an uri resource.
Changed composer dev requirement zendframework/zend-diactoros for guzzlehttp/psr7 due to the fact that zend-diactoros DiactorosStreamFactory's createStream function runs a rewind which throws an exception if stream is not seekable.
Removed dependency on Zend\Diactoros\Stream in unit tests.

…seekable streams is not fetched using string casting.

Added testSupportURIResources phpUnit test validating the multipart stream created from an uri resource.
Changed composer dev requirement zendframework/zend-diactoros for guzzlehttp/psr7 due to the fact that zend-diactoros DiactorosStreamFactory's createStream function runs a rewind which throws an exception if stream is not seekable.
Removed dependency on Zend\Diactoros\Stream in unit tests.
Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

Thank you for this PR.
Lets change back to Zend. I've submitted a PR to fix the bug you found.

php-http/message#71

@@ -15,7 +15,7 @@ public function testSupportStreams()
$body = 'stream contents';

$builder = new MultipartStreamBuilder();
$builder->addResource('foobar', $this->createStream($body));
Copy link
Member

Choose a reason for hiding this comment

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

This tests make sure we support a Stream. Please do not change this.

@@ -95,7 +95,14 @@ public function build()
$this->getHeaders($data['headers'])."\r\n";

// Convert the stream to string
$streams .= (string) $data['contents'];
/* @var $contentStream StreamInterface */
Copy link
Member

Choose a reason for hiding this comment

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

Good

composer.json Outdated
@@ -19,7 +19,7 @@
"require-dev": {
"phpunit/phpunit": "^4.8 || ^5.4",
"php-http/message": "^1.0",
"zendframework/zend-diactoros": "^1.3.5"
"guzzlehttp/psr7": "^1.3.1"
Copy link
Member

Choose a reason for hiding this comment

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

Lets change back to zend.

@Mats
Copy link
Contributor Author

Mats commented Jan 16, 2017

Done. The uri test will fail until your PR has been merged.

@Nyholm
Copy link
Member

Nyholm commented Jan 16, 2017

Thank you. I'll see if we can come to a conclusion quickly on the PRs on php-http/message.

@Mats
Copy link
Contributor Author

Mats commented Jan 16, 2017

No problem, happy to pitch in.

@Mats
Copy link
Contributor Author

Mats commented Jan 16, 2017

Refactored some variable names in the test to mirror what has been used in the other tests.

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

I plan to merge this PR next week. The changes requested from php-http/message has been merged, just waiting for a new tag.

/* @var $contentStream StreamInterface */
$contentStream = $data['contents'];
if ($contentStream->isSeekable()) {
$streams .= (string) $data['contents'];
Copy link
Member

Choose a reason for hiding this comment

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

Even though the output it the same. I think I would like to change this line to:

$streams .= $contentStream->_toString();

It will increase readability.

Copy link
Contributor Author

@Mats Mats Feb 12, 2017

Choose a reason for hiding this comment

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

Great to hear you plan to merge the PR next week. I agree with your comment about readability and have made the change from string casting to explicitly calling __toString().

Copy link
Member

Choose a reason for hiding this comment

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

Awesome. Thank you.

…explicitly calling __toString() for clarity as suggested by @Nyholm
@Nyholm
Copy link
Member

Nyholm commented Feb 14, 2017

It works with message 1.5.0

Thank you.

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.

2 participants