Skip to content

Server: header size exceeded when streaming request #456

@bartvanhoutte

Description

@bartvanhoutte

👋 When streaming a large request (7MB jpg) I get the following error: OverflowException: Maximum header size of 8192 exceeded. in /opt/project/vendor/react/http/src/Io/RequestHeaderParser.php:43.

The error can be reproduced with the following snippet:

<?php

declare(strict_types=1);

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

use React\Http\HttpServer;
use React\Http\Message\Response;
use React\Http\Middleware\StreamingRequestMiddleware;
use React\Socket\SocketServer;

$server = new HttpServer(
  new StreamingRequestMiddleware,
  fn() => new Response
);

$server->on('error', function (Throwable $t) {
    fwrite(STDERR, (string)$t);
});

$socket = new SocketServer('0.0.0.0:8080');
$server->listen($socket);

I'm using react/http 1.6.0.

I'm trying to understand what goes on behind the curtain but can't quite figure it out. The listener that handles data coming from the connection should be removed in the RequestHeaderParser but since a new instance of the parser is made whenever data comes in from the connection the error is thrown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions