react-http2/tests/Header/HeaderPackerTest.php

48 lines
1.1 KiB
PHP
Raw Normal View History

2024-02-24 19:44:06 +00:00
<?php
namespace NoccyLabs\React\Http2\Header;
use PHPUnit\Framework\Attributes\CoversClass;
#[CoversClass(HeaderBag::class)]
#[CoversClass(HeaderPacker::class)]
class HeaderPackerTest extends \PHPUnit\Framework\TestCase
{
public function testUnpackingExamplesFromRfc7541()
{
$packer = new HeaderPacker();
$in = "\x82\x86\x84\x41\x8c\xf1\xe3\xc2\xe5\xf2\x3a\x6b\xa0\xab\x90\xf4\xff";
$expect = new HeaderBag([
':method' => 'GET',
':scheme' => 'http',
':path' => '/',
':authority' => 'www.example.com'
]);
$out = $packer->unpackHeaders($in);
$this->assertEquals($expect, $out);
}
2024-02-25 14:49:14 +00:00
public function testPackingExamplesFromRfc7541()
{
$packer = new HeaderPacker();
$expect = "\x82\x86\x84\x41\x8c\xf1\xe3\xc2\xe5\xf2\x3a\x6b\xa0\xab\x90\xf4\xff";
$in = new HeaderBag([
':method' => 'GET',
':scheme' => 'http',
':path' => '/',
':authority' => 'www.example.com'
]);
$out = $packer->packHeaders($in);
$this->assertEquals($expect, $out);
}
2024-02-24 19:44:06 +00:00
2024-02-25 14:49:14 +00:00
}