PHP code example of alexpts / http-message-parser
1. Go to this page and download the library: Download alexpts/http-message-parser library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alexpts / http-message-parser example snippets
use PTS\ParserPsr7\Factory\Psr7Factory;
ET / 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"