Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue sending messages with more than 65,535 characters #15

Closed
rbro opened this issue Jan 28, 2018 · 2 comments
Closed

issue sending messages with more than 65,535 characters #15

rbro opened this issue Jan 28, 2018 · 2 comments
Assignees
Milestone

Comments

@rbro
Copy link

rbro commented Jan 28, 2018

I am running into an issue when trying to send a message body with more than 65,535 characters.

When running the below send.php, listener.php responds with "length: 0". If you change $content to be 65535 characters, then it responds correctly with "length: 65535".

send.php:

<?php
require('vendor/autoload.php');

use hollodotme\FastCGI\Client;
use hollodotme\FastCGI\Requests\PostRequest;
use hollodotme\FastCGI\SocketConnections\NetworkSocket;

$client = new Client(new NetworkSocket('127.0.0.1', 9000));

$content = str_repeat('a', 65536);

$request = new PostRequest(__DIR__.'/listener.php', $content);

$response = $client->sendRequest($request);

echo $response->getBody();
exit;

listener.php:

<?php
echo 'length: '.strlen(file_get_contents('php://input'));
@hollodotme hollodotme self-assigned this Jan 28, 2018
@hollodotme
Copy link
Owner

@rbro after debugging and researching for hours, I finally found the cause:

The FastCGI specification says:

contentData: Between 0 and 65535 bytes of data, interpreted according to the record type.

Until now, only one content packet is sent to php-fpm for a request, that's why it is limited to 65535 characters/bytes. This issue seems to be in the client implementation from the beginning (in the original one and mine - for about 7 years).

I already have tested a working solution by sending chunks of content packets. Let me finalize it and bump a new bugfix release.

Thanks for this, you're obviously the first hitting this "edge case".

@rbro
Copy link
Author

rbro commented Jan 29, 2018

@hollodotme thanks so much for the quick fix. It works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants