Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Jul 4, 2024
1 parent d1f93df commit de7e217
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tests/swoole_http2_client_coro/connect_twice.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,33 @@ swoole_http2_client_coro: connect twice
<?php
require __DIR__ . '/../include/bootstrap.php';

use Swoole\Coroutine\Channel;
use Swoole\Http2\Request;
use function Swoole\Coroutine\run;
use function Swoole\Coroutine\go;

run(function () {
$client = new \Swoole\Coroutine\Http2\Client('www.zhihu.com', 443, true);
$chan = new \Swoole\Coroutine\Channel(1);
$client = new \Swoole\Coroutine\Http2\Client('httpbin.org', 443, true);
$chan = new Channel(1);
go(function () use ($client, $chan) {
$client->connect();
$req = new Request();
$uuid = uniqid();
$req->method = 'GET';
$req->path = '/io?io=' . str_repeat('xxx', 1000);
$req->path = '/base64/' . base64_encode($uuid);
$client->send($req);
$chan->push(true);
$resp = $client->recv();
Assert::eq($resp->statusCode, 200);
Assert::contains($resp->data, '知乎');
Assert::eq($resp->data, $uuid);
$chan->pop();
});
go(function () use ($client, $chan) {
Assert::eq($client->connect(), false);
$uuid = uniqid();
$req = new Request();
$req->method = 'GET';
$req->path = '/io?io=xxx';
$req->path = '/base64/' . base64_encode($uuid);
$client->send($req);
$chan->push(true);
Assert::eq($client->recv(), false);
Expand Down

0 comments on commit de7e217

Please sign in to comment.