@@ -716,6 +716,28 @@ public function testGetPort()
716
716
$ port = $ request ->getPort ();
717
717
718
718
$ this ->assertEquals (80 , $ port , 'If X_FORWARDED_PROTO is set to http return 80. ' );
719
+
720
+ //On
721
+ $ request = Request::create ('http://example.com ' , 'GET ' , array (), array (), array (), array (
722
+ 'HTTP_X_FORWARDED_PROTO ' => 'On '
723
+ ));
724
+ $ port = $ request ->getPort ();
725
+ $ this ->assertEquals (443 , $ port , 'With only PROTO set and value is On, getPort() defaults to 443. ' );
726
+
727
+ //1
728
+ $ request = Request::create ('http://example.com ' , 'GET ' , array (), array (), array (), array (
729
+ 'HTTP_X_FORWARDED_PROTO ' => '1 '
730
+ ));
731
+ $ port = $ request ->getPort ();
732
+ $ this ->assertEquals (443 , $ port , 'With only PROTO set and value is 1, getPort() defaults to 443. ' );
733
+
734
+ //something-else
735
+ $ request = Request::create ('http://example.com ' , 'GET ' , array (), array (), array (), array (
736
+ 'HTTP_X_FORWARDED_PROTO ' => 'something-else '
737
+ ));
738
+ $ port = $ request ->getPort ();
739
+ $ this ->assertEquals (80 , $ port , 'With only PROTO set and value is not recognized, getPort() defaults to 80. ' );
740
+
719
741
Request::setTrustedProxies (array ());
720
742
}
721
743
0 commit comments