PHPackages                             vircom/http-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. vircom/http-parser

ActiveLibrary[HTTP &amp; Networking](/categories/http)

vircom/http-parser
==================

HTTP requests and responses parser library

1.0.1(6y ago)120MITPHPPHP ^7.4CI failing

Since Apr 27Pushed 6y ago1 watchersCompare

[ Source](https://github.com/vircom/http-parser)[ Packagist](https://packagist.org/packages/vircom/http-parser)[ RSS](/packages/vircom-http-parser/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)Dependencies (6)Versions (3)Used By (0)

vircom/http-parser
==================

[](#vircomhttp-parser)

---

[![Build Status](https://camo.githubusercontent.com/faf91caa32d98b302c2993ad4406fe907debda0eb7dc4beb841e6b4c9eaa17f5/68747470733a2f2f7472617669732d63692e6f72672f766972636f6d2f687474702d7061727365722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vircom/http-parser)[![Coverage Status](https://camo.githubusercontent.com/ba8f58fcca84b2e960aca6d42da0a28971185ef0716defd4d5f1b095d9e0ab8f/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f766972636f6d2f687474702d7061727365722f62616467652e737667)](https://coveralls.io/github/vircom/http-parser)[![Latest Stable Version](https://camo.githubusercontent.com/3e41f50c5dc730300366378a26513fcd46fcc77388f82e2f3641bd09ac9ad24a/68747470733a2f2f706f7365722e707567782e6f72672f766972636f6d2f687474702d7061727365722f762f737461626c652e706e67)](https://packagist.org/packages/vircom/http-parser)[![Total Downloads](https://camo.githubusercontent.com/e3e07668d9fff873a352dc23e858fe74b05716f41162c6fb08daea57588d0049/68747470733a2f2f706f7365722e707567782e6f72672f766972636f6d2f687474702d7061727365722f646f776e6c6f6164732e706e67)](https://packagist.org/vircom/http-parser)[![License](https://camo.githubusercontent.com/fbd4ff52aad8ef0741c1036fa2a668351d295ea337fdd8d7a269037b60e8d31f/68747470733a2f2f706f7365722e707567782e6f72672f766972636f6d2f687474702d7061727365722f6c6963656e73652e706e67)](https://packagist.org/packages/vircom/http-parser)

This package provides an implementation to parse raw HTTP request and responses.

Prerequisites
=============

[](#prerequisites)

- PHP 7.4+

Installation
============

[](#installation)

Install by composer
-------------------

[](#install-by-composer)

To install vircom/http-parser with Composer, run the following command:

```
$ composer require vircom/http-parser
```

You can see this library on [Packagist](https://packagist.org/packages/vircom/http-parser).

Composer installs autoloader at `./vendor/autoloader.php`. If you use vircom/http-parser in your php script, add:

```
require_once 'vendor/autoload.php';
```

Usage:
======

[](#usage)

Parsing request
---------------

[](#parsing-request)

```
use VirCom\HttpParser\HttpParserFactory;

$request = "POST /cgi-bin/process.cgi HTTP/0.9\r\n"
 . "User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)\r\n"
 . "\r\n"
 . "exampleName1=exampleValue1&exampleName2=exampleValue2";

$parser = (new HttpParserFactory())->createRequestParser();
$result = $parser->parse($request);
```

Parsing response
----------------

[](#parsing-response)

```
