public function testChunkedData()
 {
     $data = "GET /democracy/init HTTP/1.1\r\nUser-Agent: The Illuminati/2.0\r\nContent-Type: text/plain\r\nTransfer-Encoding: chunked\r\n\r\n1a; ignore-stuff-here\r\nabcdefghijklmnopqrstuvwxyz\r\n10\r\n1234567890abcdef\r\n0\r\n";
     $requestParser = new RequestParser();
     $result = $requestParser->addData($data);
     $this->assertTrue($result);
     $this->assertTrue($requestParser->isFullyRead());
     $this->assertEquals(RequestParser::OK, $requestParser->getStatus());
 }
<?php

require_once __DIR__ . '/../vendor/autoload.php';
use sekjun9878\RequestParser\RequestParser;
use sekjun9878\RequestParser\Request;
$header_str = "GET /democracy/init HTTP/1.1\r\nUser-Agent: The Illuminati/2.0\r\nContent-Length: 10\r\n\r\nOver 9000!";
$requestParser = new RequestParser();
$requestParser->addData($header_str);
$request = Request::create($requestParser->exportRequestState());
var_dump($request->getHeaders());
var_dump($request->getBody());
<?php

require_once __DIR__ . '/../vendor/autoload.php';
use sekjun9878\RequestParser\RequestParser;
use sekjun9878\RequestParser\Request;
$address = "127.0.0.1";
$port = 8080;
$listenSocket = stream_socket_server("tcp://{$address}:{$port}");
$connectionSocket = stream_socket_accept($listenSocket);
$requestParser = new RequestParser();
$error = false;
while (!$requestParser->isFullyRead()) {
    $data = fread($connectionSocket, RequestParser::READ_SIZE);
    if (!$requestParser->addData($data)) {
        fclose($connectionSocket);
        fclose($listenSocket);
        exit(1);
    }
}
if ($requestParser->getStatus() !== RequestParser::OK) {
    switch ($requestParser->getStatus()) {
        case RequestParser::BAD_REQUEST:
            fwrite($connectionSocket, "HTTP/1.1 400 Bad Request\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length: " . mb_strlen("<html><head><title>400 Bad Request</title></head><body><h1>400 Bad Request</h1></body></html>") . "\r\n\r\n" . "<html><head><title>400 Bad Request</title></head><body><h1>400 Bad Request</h1></body></html>");
            fclose($connectionSocket);
            fclose($listenSocket);
            exit(1);
            break;
        case RequestParser::INTERNAL_SERVER_ERROR:
        default:
            fwrite($connectionSocket, "HTTP/1.1 500 Internal Server Error\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length: " . mb_strlen("<html><head><title>500 Internal Server Error</title></head><body><h1>500 Internal Server Error</h1></body></html>") . "\r\n\r\n" . "<html><head><title>500 Internal Server Error</title></head><body><h1>500 Internal Server Error</h1></body></html>");
            fclose($connectionSocket);