Last active
July 7, 2024 20:21
-
-
Save masakielastic/8840124754b38663373f8f74d6f162d4 to your computer and use it in GitHub Desktop.
HTTP/2 frames test data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function dump($chunk, $name) { | |
var_dump( | |
$name, | |
[ | |
'size' => strlen($chunk), | |
'hex' => bin2hex($chunk) | |
] | |
); | |
} | |
function h2frames($name) { | |
$frames = []; | |
$frames['pri'] = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"; | |
$frames['settings'] = "\x00\x00\x0C". | |
"\x04". | |
"\x00". | |
"\x00\x00\x00\x00". | |
"\x00\x02\x00\x00\x00\x00". | |
"\x00\x03\x00\x00\x00\x64"; | |
$frames['ack'] = "\x00\x00\x00". | |
"\x04". | |
"\x01". | |
"\x00\x00\x00\x00"; | |
$frames['headers'] = "\x00\x00\x3a". | |
"\x01". | |
"\x05". | |
"\x00\x00\x00\x01". | |
"\x00". | |
"\x07:method". // 7 :method | |
"\x03\x47\x45\x54". // 3 GET | |
"\x00". | |
"\x05\x3a\x70\x61\x74\x68". // 5 :path | |
"\x01\x2f". // 1 / | |
"\x00". | |
"\x07\x3a\x73\x63\x68\x65\x6d\x65". // 7 :scheme | |
"\x04http". // 4 http | |
"\x00". | |
"\x0a\x3a\x61\x75\x74\x68\x6f\x72\x69\x74\x79". // 10 :authority | |
"\x09localhost"; // 9 localhost | |
return $frames[$name]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment