File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -20,8 +20,11 @@ public function handleClose()
2020 return ;
2121 }
2222
23- // http://chat.stackoverflow.com/transcript/message/7727858#7727858
24- stream_socket_shutdown ($ this ->stream , STREAM_SHUT_RDWR );
23+ // Try to cleanly shut down socket and ignore any errors in case other
24+ // side already closed. Shutting down may return to blocking mode on
25+ // some legacy versions, so reset to non-blocking just in case before
26+ // continuing to close the socket resource.
27+ @stream_socket_shutdown ($ this ->stream , STREAM_SHUT_RDWR );
2528 stream_set_blocking ($ this ->stream , false );
2629 fclose ($ this ->stream );
2730 }
Original file line number Diff line number Diff line change @@ -81,6 +81,24 @@ public function gettingEncryptedStuffFromGoogleShouldWorkIfHostIsResolvedFirst()
8181 $ this ->assertRegExp ('#^HTTP/1\.0# ' , $ response );
8282 }
8383
84+ /** @test */
85+ public function gettingPlaintextStuffFromEncryptedGoogleShouldNotWork ()
86+ {
87+ $ loop = new StreamSelectLoop ();
88+ $ connector = new Connector ($ loop );
89+
90+ $ conn = Block \await ($ connector ->connect ('google.com:443 ' ), $ loop );
91+
92+ $ this ->assertContains (':443 ' , $ conn ->getRemoteAddress ());
93+ $ this ->assertNotEquals ('google.com:443 ' , $ conn ->getRemoteAddress ());
94+
95+ $ conn ->write ("GET / HTTP/1.0 \r\n\r\n" );
96+
97+ $ response = Block \await (BufferedSink::createPromise ($ conn ), $ loop , self ::TIMEOUT );
98+
99+ $ this ->assertNotRegExp ('#^HTTP/1\.0# ' , $ response );
100+ }
101+
84102 /** @test */
85103 public function testConnectingFailsIfDnsUsesInvalidResolver ()
86104 {
You can’t perform that action at this time.
0 commit comments