Nette\Http\RequestFactory.php gives “TypeError: trim() expects parameter 1 to be string, bool given”

10 days ago

pupitooo
Member | 11
+
0
-

I am migrating from 2.4 to 3.0 and I have problem with settings of http.proxy

For example here it test:

<?php
test(function () {
	$_SERVER = [
		'REMOTE_ADDR' => '172.18.0.6',
		'HTTP_X_FORWARDED_FOR' => '172.18.0.1',
	];

	$factory = new RequestFactory();
	$factory->setProxy('172.16.0.0/12');

	Assert::same('172.18.0.1', $factory->fromGlobals()->getRemoteAddress()); // here I am not sure if I expect right IP
});
?>

And this fails with TypeError: trim() expects parameter 1 to be string, bool given on line: https://github.com/…tFactory.php#L336

Could anyone help me? I am not sure if everything in Nette\Http is ok and fail is on my side or this is real bug in Nette\Http. And if this is bug I am not sure what should return.

If you send me anything what I should read/watch to better understand this I would be more than happy:)

Thanks!

10 days ago

CZechBoY
Member | 3430
+
0
-

With this code you are saying that mentioned ips are all proxies. So Nette cannot tell you the client’s ip.