-
-
Notifications
You must be signed in to change notification settings - Fork 143
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
Conversation
if (isset($remoteAddress['port'])) { | ||
$serverParams['REMOTE_ADDR'] = $remoteAddress['host']; | ||
$serverParams['REMOTE_PORT'] = $remoteAddress['port']; | ||
} |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this 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" . ''); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Partial UDS support for #231