alexpts / http-message-parser
Parser http message and convert to PSR7 and back
0.0.3
2022-05-29 11:06 UTC
Requires
- php: ~8.1
- alexpts/mutable-psr7: ^0.2.1
- psr/http-message: ^1.0
Requires (Dev)
- phpbench/phpbench: ^1.2
- phpunit/phpunit: ^9.5
README
composer require alexpts/http-message-parser
Very fast parser for http message.
- Create PSR-7 request/response from http message
- Create http message from PSR-7 request/response
- SapiEmitter
<?php use PTS\ParserPsr7\Factory\Psr7Factory; include_once 'vendor/autoload.php'; $factory = new Psr7Factory; $httpMessage = "GET / HTTP 1.0\r\nconnection:keep-alive\r\nh1: v1 \r\nuser: 1\r\n\r\n"; $psr7Request = $factory->toPsr7Request($httpMessage); $httpMessage2 = $factory->toMessageRequest($psr7Request); // "GET / HTTP 1.0\r\nconnection:keep-alive\r\nh1:v1\r\nuser:1\r\n\r\n" $httpMessage = "HTTP/1.1 404 Not Found\r\n\r\n"; $psr7Response = $factory->toPsr7Request($httpMessage); $httpMessage2 = $factory->toMessageRequest($psr7Response); // "HTTP/1.1 404 Not Found\r\n\r\n"
Benchmark Tests
composer bench