fix and add test

This commit is contained in:
sy-records 2020-06-16 14:54:33 +08:00
parent 7994e552ac
commit 1ca339fa06
2 changed files with 3 additions and 1 deletions

View File

@ -439,7 +439,7 @@ class Request extends \Hyperf\HttpMessage\Base\Request implements ServerRequestI
*/
public function isXmlHttpRequest()
{
return $this->getHeader('X-Requested-With') == 'XMLHttpRequest';
return $this->getHeaderLine('X-Requested-With') == 'XMLHttpRequest';
}
public function getSwooleRequest(): \Swoole\Http\Request

View File

@ -29,11 +29,13 @@ class MessageTraitTest extends TestCase
'X-Id' => $id,
'Version' => 1.0,
1000 => 1000,
'X-Requested-With' => 'XMLHttpRequest',
]);
$this->assertSame($token, $request->getHeaderLine('X-Token'));
$this->assertSame((string) $id, $request->getHeaderLine('X-Id'));
$this->assertSame('1', $request->getHeaderLine('Version'));
$this->assertSame('1000', $request->getHeaderLine('1000'));
$this->assertSame('XMLHttpRequest', $request->getHeaderLine('X-Requested-With'));
}
}