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

Reuse stream of HTTP request instead of create new stream #12

Merged
merged 2 commits into from
Dec 16, 2020

Conversation

ElGigi
Copy link
Contributor

@ElGigi ElGigi commented Dec 2, 2020

Reuse stream of HTTP request instead of create new stream.

If you can test with your test environment ;).

@RoyVoetman
Copy link
Owner

RoyVoetman commented Dec 2, 2020

It does not seem to work properly when reusing the guzzle stream

1) GitlabAdapterTest::it_can_read_a_file_into_a_stream
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-''
+'# Testing repo for `flysystem-gitlab`'

GitlabAdapterTest.php:81

@RoyVoetman
Copy link
Owner

Changed:

$this->assertEquals(stream_get_contents($stream, null, 0), $this->gitlabAdapter->read('README.md'));

To:

$this->assertEquals(stream_get_contents($stream), $this->gitlabAdapter->read('README.md'));

Results:
There was 1 failure:

  1. GitlabAdapterTest::it_can_read_a_file_into_a_stream
    Failed asserting that two strings are equal.
    --- Expected
    +++ Actual
    @@ @@
    -'{"file_name":"README.md","file_path":"README.md","size":37,"encoding":"base64","content_sha256":"e9492f2d51b0021ed15b97ecf8780ccd119f3628786de41aaff546aa126584d1","ref":"master","blob_id":"5762108fe413276c03951c653ac041c79e39c279","commit_id":"60324fe92d19b865684c7e5c59390fa32d0b13f8","last_commit_id":"ec1ac4fbb877266574474a7913f9f47ca548cfe1","content":"IyBUZXN0aW5nIHJlcG8gZm9yIGBmbHlzeXN0ZW0tZ2l0bGFiYA=="}'
    +'# Testing repo for flysystem-gitlab'

GitlabAdapterTest.php:81

FAILURES!
Tests: 1, Assertions: 2, Failures: 1.

@ElGigi
Copy link
Contributor Author

ElGigi commented Dec 8, 2020

Yes, my bad! JSON result... so not possible to reuse stream.

@ElGigi ElGigi closed this Dec 8, 2020
@ElGigi ElGigi reopened this Dec 16, 2020
@ElGigi
Copy link
Contributor Author

ElGigi commented Dec 16, 2020

I read the API documentation; I hadn't seen the "../raw" route; so it works!

@RoyVoetman
Copy link
Owner

Nice! I should have known this, I even implemented a readRaw method in the client. Thanks for putting in the effort, I will add this in the new version when I have the time to test it in the testing environment.

@RoyVoetman RoyVoetman merged commit f57138c into RoyVoetman:master Dec 16, 2020
@ElGigi ElGigi deleted the reuse-stream branch May 16, 2022 10:25
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