Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft committed Dec 6, 2019
2 parents e76547f + ca427be commit 1f9ed4d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,21 @@ matrix:
env: SWOOLE_VERSION="v4.4.12"
- php: '7.3'
env: SWOOLE_VERSION="v4.4.12"
- php: '7.4'
env: SWOOLE_VERSION="v4.4.12"
- php: '7.1'
env: SWOOLE_VERSION="master"
- php: '7.2'
env: SWOOLE_VERSION="master"
- php: '7.3'
env: SWOOLE_VERSION="master"
- php: '7.4snapshot'
env: SWOOLE_VERSION="master" DISABLE_XDEBUG=false PHPUNIT_VERSION="7"
- php: '7.4'
env: SWOOLE_VERSION="master"
- php: 'nightly'
env: SWOOLE_VERSION="master" DISABLE_XDEBUG=false PHPUNIT_VERSION="7" INSTALL_REDIS_EXT=true
allow_failures:
- env: SWOOLE_VERSION="master"
- php: nightly
- php: 7.4snapshot

env:
global:
Expand Down
12 changes: 11 additions & 1 deletion src/YurunHttp/Handler/Swoole.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,17 @@ public function buildRequest($request, $connection, &$http2Request)
{
$http2Request->headers = $headers;
$http2Request->pipeline = $request->getAttribute(Attributes::HTTP2_PIPELINE, false);
$http2Request->path = $uri->getPath();
$path = $uri->getPath();
if('' === $path)
{
$path = '/';
}
$query = $uri->getQuery();
if('' !== $query)
{
$path .= '?' . $query;
}
$http2Request->path = $path;
}
else
{
Expand Down
8 changes: 8 additions & 0 deletions tests/server/Http2/http2-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
'fd' => $request->fd,
]));
break;
case '/get':
$response->header('trailer', 'yurun');
$response->trailer('yurun', 'niubi');
$response->end(json_encode([
'date' => $request->get['date'] ?? time(),
'fd' => $request->fd,
]));
break;
case '/sleep':
$data = json_decode($request->rawcontent(), true);
Coroutine::sleep(1);
Expand Down
27 changes: 27 additions & 0 deletions tests/unit/Http2/SwooleHttp2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,33 @@ public function testHttp2()
});
}

public function testHttp2ByUrl()
{
$this->call(function(){
$http = new HttpRequest;
$http->protocolVersion = '2.0';
$http->timeout = 3000;

$date = strtotime('2017-03-24 17:12:14');
$response = $http->post($this->http2Host . 'get?date=' . $date);
$data = $response->json(true);
$this->assertEquals($date, isset($data['date']) ? $data['date'] : null);
$this->assertGreaterThan(1, isset($data['fd']) ? $data['fd'] : null);
$this->assertEquals('yurun', $response->getHeaderLine('trailer'));
$this->assertEquals('niubi', $response->getHeaderLine('yurun'));

$date = strtotime('2017-03-29 10:50:51');
$response = $http->post($this->http2Host, [
'date' => $date,
], 'json');
$data2 = $response->json(true);
$this->assertEquals($date, isset($data2['date']) ? $data2['date'] : null);
$this->assertEquals($data['fd'], isset($data2['fd']) ? $data2['fd'] : null);
$this->assertEquals('yurun', $response->getHeaderLine('trailer'));
$this->assertEquals('niubi', $response->getHeaderLine('yurun'));
});
}

public function testMuiltCo()
{
$this->call(function(){
Expand Down

0 comments on commit 1f9ed4d

Please sign in to comment.