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

replace guzzle with amphp/http-client and revolt/event-loop #500

Merged
merged 30 commits into from
Jul 10, 2024

Conversation

unglaublicherdude
Copy link
Member

No description provided.

@unglaublicherdude unglaublicherdude changed the base branch from main to php_ping_on_upload July 2, 2024 07:41
@unglaublicherdude unglaublicherdude force-pushed the replace-guzzle-with-react-http branch from f158302 to 42c969c Compare July 2, 2024 10:35
@unglaublicherdude
Copy link
Member Author

The order matters, when using the react/event-loop because one http-request can consume the readstream that accidental also in the loop. See this issue for that.

For a better understanding I added this test

What you see is, that with the second http request in a second browser the first stream is getting consumed even though the stream is completely unrelated to the second browser.

@unglaublicherdude unglaublicherdude marked this pull request as ready for review July 2, 2024 10:36
@unglaublicherdude unglaublicherdude force-pushed the replace-guzzle-with-react-http branch 2 times, most recently from 3a6a9af to 5a713cf Compare July 2, 2024 10:40
@unglaublicherdude
Copy link
Member Author

unglaublicherdude commented Jul 2, 2024

I also opened this discussion here.

@unglaublicherdude
Copy link
Member Author

I also opened this issue.

@unglaublicherdude unglaublicherdude changed the base branch from php_ping_on_upload to main July 3, 2024 21:09
@unglaublicherdude unglaublicherdude changed the title Replace guzzle with react http replace guzzle with amphp/http-client and revolt/event-loop Jul 3, 2024
@unglaublicherdude
Copy link
Member Author

I completely replaced react with amphp and revolt which works as expected. Streams are not getting touched before something is actually consuming them.

@unglaublicherdude
Copy link
Member Author

Dunno why it did not start the pipeline. Here is manual run of these changes.

.github/workflows/image-retention.yaml Show resolved Hide resolved
php/src/vaas/Vaas.php Outdated Show resolved Hide resolved
php/src/vaas/Vaas.php Outdated Show resolved Hide resolved
$verdictResponse = $this->_verdictResponseForStream(
$uuid
);
$this->_logger->debug("uuid: ".var_export($uuid, true));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Considering that uuid is typed to be a string, isn't the var_export a bit too much here? A simple . $uuid should suffice I think.

);
$this->_logger->debug("uuid: ".var_export($uuid, true));
$uuid = $uuid !== null ? $uuid : UuidV4::getFactory()->uuid4()->toString();
$this->_logger->debug("uuid: ".var_export($uuid, true));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Double debug print looks like this is a leftover from debugging. A single print in this line is enough debug logging IMHO.

Copy link
Member Author

Choose a reason for hiding this comment

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

Both where debugging stuff before I found out, that in VSCode you just have to start the debugger first, then you will basically debug anything you run in php like starting the test from the testexplorer but also from console. That made my life so much easier.

php/tests/vaas/VaasTest.php Outdated Show resolved Hide resolved

$this->assertEquals(Verdict::MALICIOUS, $verdict->Verdict);
$this->assertEquals("text/plain", $verdict->MimeType);
$this->assertNotEmpty($verdict->Detection);
}

static function random_strings($length_of_string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a duplicate function here.

static function random_strings($length_of_string) {

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes. I had problems calling stuff from another class and just copied it here. And in the end, I don't need it anymore. Will remove it.

php/src/vaas/Authentication/OAuth2TokenReceiver.php Outdated Show resolved Hide resolved
@unglaublicherdude unglaublicherdude force-pushed the replace-guzzle-with-react-http branch from 68be70d to 3c717c5 Compare July 5, 2024 08:28

$verdict = $vaas->ForStream($stream);
/**
* @throws GuzzleException
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems corrupted. Guzzle is completely removed (?)

Copy link
Contributor

@pstadermann pstadermann left a comment

Choose a reason for hiding this comment

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

Very nice! Only one comment from me.

@unglaublicherdude unglaublicherdude merged commit c10da21 into main Jul 10, 2024
4 checks passed
@unglaublicherdude unglaublicherdude deleted the replace-guzzle-with-react-http branch July 10, 2024 07:55
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.

5 participants