@@ -133,7 +133,67 @@ public function testRequestFromGlobalsWithConnectProxy(): void
133133 $ request = $ sapi ->requestFromGlobals ();
134134
135135 $ this ->assertEquals ('CONNECT ' , $ request ->getMethod ());
136- $ this ->assertEquals ('example.com:443 ' , (string ) $ request ->getUri ());
136+ $ this ->assertEquals ('http://example.com:443 ' , (string ) $ request ->getUri ());
137+ $ this ->assertEquals ('example.com:443 ' , $ request ->getRequestTarget ());
138+ $ this ->assertEquals ('1.1 ' , $ request ->getProtocolVersion ());
139+ $ this ->assertEquals ('example.com:443 ' , $ request ->getHeaderLine ('Host ' ));
140+ }
141+
142+ /**
143+ * @backupGlobals enabled
144+ */
145+ public function testRequestFromGlobalsWithConnectProxyWithDefaultHttpPort (): void
146+ {
147+ $ _SERVER ['REQUEST_METHOD ' ] = 'CONNECT ' ;
148+ $ _SERVER ['REQUEST_URI ' ] = 'example.com:80 ' ;
149+ $ _SERVER ['SERVER_PROTOCOL ' ] = 'http/1.1 ' ;
150+ $ _SERVER ['HTTP_HOST ' ] = 'example.com ' ;
151+
152+ $ sapi = new SapiHandler ();
153+ $ request = $ sapi ->requestFromGlobals ();
154+
155+ $ this ->assertEquals ('CONNECT ' , $ request ->getMethod ());
156+ $ this ->assertEquals ('http://example.com ' , (string ) $ request ->getUri ());
157+ $ this ->assertEquals ('example.com:80 ' , $ request ->getRequestTarget ());
158+ $ this ->assertEquals ('1.1 ' , $ request ->getProtocolVersion ());
159+ $ this ->assertEquals ('example.com ' , $ request ->getHeaderLine ('Host ' ));
160+ }
161+
162+ /**
163+ * @backupGlobals enabled
164+ */
165+ public function testRequestFromGlobalsWithConnectProxyWithoutHostHeader (): void
166+ {
167+ $ _SERVER ['REQUEST_METHOD ' ] = 'CONNECT ' ;
168+ $ _SERVER ['REQUEST_URI ' ] = 'example.com:8080 ' ;
169+ $ _SERVER ['SERVER_PROTOCOL ' ] = 'http/1.1 ' ;
170+
171+ $ sapi = new SapiHandler ();
172+ $ request = $ sapi ->requestFromGlobals ();
173+
174+ $ this ->assertEquals ('CONNECT ' , $ request ->getMethod ());
175+ $ this ->assertEquals ('http://example.com:8080 ' , (string ) $ request ->getUri ());
176+ $ this ->assertEquals ('example.com:8080 ' , $ request ->getRequestTarget ());
177+ $ this ->assertEquals ('1.1 ' , $ request ->getProtocolVersion ());
178+ $ this ->assertFalse ($ request ->hasHeader ('Host ' ));
179+ }
180+
181+ /**
182+ * @backupGlobals enabled
183+ */
184+ public function testRequestFromGlobalsWithConnectProxyOverHttps (): void
185+ {
186+ $ _SERVER ['REQUEST_METHOD ' ] = 'CONNECT ' ;
187+ $ _SERVER ['REQUEST_URI ' ] = 'example.com:443 ' ;
188+ $ _SERVER ['SERVER_PROTOCOL ' ] = 'http/1.1 ' ;
189+ $ _SERVER ['HTTP_HOST ' ] = 'example.com:443 ' ;
190+ $ _SERVER ['HTTPS ' ] = 'on ' ;
191+
192+ $ sapi = new SapiHandler ();
193+ $ request = $ sapi ->requestFromGlobals ();
194+
195+ $ this ->assertEquals ('CONNECT ' , $ request ->getMethod ());
196+ $ this ->assertEquals ('https://example.com ' , (string ) $ request ->getUri ());
137197 $ this ->assertEquals ('example.com:443 ' , $ request ->getRequestTarget ());
138198 $ this ->assertEquals ('1.1 ' , $ request ->getProtocolVersion ());
139199 $ this ->assertEquals ('example.com:443 ' , $ request ->getHeaderLine ('Host ' ));
0 commit comments