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

Prevent exception if underlying socket is a unix socket #234

Closed
wants to merge 2 commits into from

Conversation

andig
Copy link
Contributor

@andig andig commented Oct 4, 2017

Partial UDS support for #231

if (isset($remoteAddress['port'])) {
$serverParams['REMOTE_ADDR'] = $remoteAddress['host'];
$serverParams['REMOTE_PORT'] = $remoteAddress['port'];
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the REMOTE_ADDR should still be set, no? I guess the port could just be set to 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of OSX I get ________ as REMOTE_ADDR so I've removed both.

Copy link
Member

@clue clue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for filing this PR! I would like to look into this in more detail, can you add a test case that triggers this behavior and the expected output? 👍

public function testUnixRemoteSocketWithoutPort()
{
// reactphp/socket Connect->parseAddress returns "tcp://NUL" for UDS
$parser = new RequestHeaderParser(null, 'tcp://' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why these empty string concatenations?

Copy link
Contributor Author

@andig andig Oct 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://bugs.php.net/bug.php?id=74556. Thats what PHP returns for stream address of UDS on OSX. I would appreciated upvotes on the bug.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andig Thanks for the update!

Have you seen reactphp/socket#100? IMO this should be handled by the Socket component, which is also where this address comes from (afaict). This way, we would likely expect a null address here. Does this make sense to you?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you want upvotes on an already fixed bug? But it's not what I asked. You write "\0" . '' . "\0" there instead of simply "\0\0", why that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You write "\0" . '' . "\0" there instead of simply "\0\0", why that?

That was copy/paste from var_export, will fix.

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

Successfully merging this pull request may close these issues.

3 participants