Skip to content

Error when sending large messages over secure HTTPS with older PHP versions #60

@pwhelan

Description

@pwhelan

When sending large contents via POST, specifically images (~90kb+) the connection simply hangs. I have already filed the same bug in for the WyriHaximus guzzle adapter here: WyriHaximus/react-guzzle-psr7#10.

Here is some short example code:

<?php

require_once 'vendor/autoload.php';


$mp = new p3k\Multipart;
$mp->addPart('field', 'value');
$mp->addFile('file', 'large-image', 'image/jpeg');

$url = "https://example.com";

$loop = React\EventLoop\Factory::create();
$dnsFactory = new React\Dns\Resolver\Factory();
$dns = $dnsFactory->createCached('192.168.2.1', $loop);
$factory = new React\HttpClient\Factory();
$client = $factory->create($loop, $dns);

$loop->nextTick(function() use ($client, $url, $mp) {

    $request = $client->request("POST", $url, [
        'Content-Type'      => $mp->contentType(),
        'Content-Length'    => strlen($mp->data())
    ]);

    $request->on('response', function($response) {
        print "WE HAVE RESPONSE: ".$response->getCode()."\n";
        print_r($response->getHeaders());
        $response->on('data', function($data, $response) {
            print "DATA ...\n";
            print $data;
        });
        $response->on('end', function() {
            die("IT'S OVER!\n");
        });
    });

    $request->end($mp->data());
});

while (1) $loop->run();
print "DONE!\n";

You will need a URL to POST to as well as an image file to send. Both should not be hard to get a hold of to test this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions