2017 © Pedro PelĂĄez
 

library http-parser

A library to parse HTTP headers and HTTP header fields

image

bfunky/http-parser

A library to parse HTTP headers and HTTP header fields

  • Thursday, January 18, 2018
  • by bfunky
  • Repository
  • 2 Watchers
  • 4 Stars
  • 215 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 8 Versions
  • 12 % Grown

The README.md

HTTP Parser

Scrutinizer Code Quality Build Status Code Coverage, (*1)

A library to parse HTTP header and HTTP header fields, (*2)

Usage

Parsing a request

        $rawHttp = <<<RAW
POST /path HTTP/1.1
User-Agent: PHP-SOAP/\BeSimple\SoapClient
Host: url.com:80
Accept: */*
Accept-Encoding: deflate, gzip
Content-Type:text/xml; charset=utf-8
Content-Length: 1108
Expect: 100-continue

RAW;
        /**
         * Managing Http fields
         */
        $parser = new HttpRequestParser();
        $parser->parse($rawHttp);
        echo $parser->get('User-Agent');
        //output PHP-SOAP/\BeSimple\SoapClient
        echo $parser->get('Host');
        //output url.com:80
        /**
         * Managing Http header
         * @var HttpRequestHeader $entityHeader
         */
        $entityHeader = $parser->getHeader();
        echo $entityHeader->getMethod();
        //output POST
        echo $entityHeader->getPath();
        //output /path
        echo $entityHeader->getProtocol();
        //output HTTP/1.1

Parsing a response

        $rawHttp = <<<RAW
        HTTP/1.1 100 Continue

        HTTP/1.1 200 OK
        Date: Tue, 12 Apr 2016 13:58:01 GMT
        Server: Apache/2.2.14 (Ubuntu)
        X-Powered-By: PHP/5.3.14 ZendServer/5.0
        Set-Cookie: ZDEDebuggerPresent=php,phtml,php3; path=/
        Set-Cookie: PHPSESSID=6sf8fa8rlm8c44avk33hhcegt0; path=/; HttpOnly
        Expires: Thu, 19 Nov 1981 08:52:00 GMT
        Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
        Pragma: no-cache
        Vary: Accept-Encoding
        Content-Encoding: gzip
        Content-Length: 192
        Content-Type: text/xml
RAW;

        /**
         * Managing Http fields
         */
        $parser = new HttpResponseParser();
        $parser->parse($raw);
        echo $parser->get('Content-Length');
        //output 192
        echo $parser->get('Content-Type');
        //output text/xml
        /**
         * Managing Http header
         * @var HttpRequestHeader $entityHeader
         */
        $entityHeader = $parser->getHeader();
        echo $entityHeader->getMessage();
        //output OK
        echo $entityHeader->getCode();
        //output 200
        echo $entityHeader->getProtocol();
        //output HTTP/1.1

The Versions

18/01 2018

dev-master

9999999-dev

A library to parse HTTP headers and HTTP header fields

  Sources   Download

MIT

The Requires

  • php 7.1.*

 

The Development Requires

parser http http request http response http parser http fields

18/01 2018

2.2.2

2.2.2.0

A library to parse HTTP headers and HTTP header fields

  Sources   Download

MIT

The Requires

  • php 7.1.*

 

The Development Requires

parser http http request http response http parser http fields

18/01 2018

2.2.1

2.2.1.0

A library to parse HTTP headers and HTTP header fields

  Sources   Download

MIT

The Requires

  • php >=7.2

 

The Development Requires

parser http http request http response http parser http fields

18/01 2018

2.2.0

2.2.0.0

A library to parse HTTP headers and HTTP header fields

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

parser http http request http response http parser http fields

07/05 2017

2.1.0

2.1.0.0

A library to parse HTTP headers and HTTP header fields

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

parser http http request http response http parser http fields

07/05 2017

2.0.0

2.0.0.0

A library to parse HTTP headers and HTTP header fields

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

parser http http request http response http parser http fields

30/04 2016

1.0.1

1.0.1.0

A library to parse HTTP headers and HTTP header fields

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

parser http http request http response http parser http fields

23/04 2016

1.0.0

1.0.0.0

A library to parse HTTP headers and HTTP header fields

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

parser http http request http response http parser http fields