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()
20
20
return ;
21
21
}
22
22
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 );
25
28
stream_set_blocking ($ this ->stream , false );
26
29
fclose ($ this ->stream );
27
30
}
Original file line number Diff line number Diff line change @@ -81,6 +81,24 @@ public function gettingEncryptedStuffFromGoogleShouldWorkIfHostIsResolvedFirst()
81
81
$ this ->assertRegExp ('#^HTTP/1\.0# ' , $ response );
82
82
}
83
83
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
+
84
102
/** @test */
85
103
public function testConnectingFailsIfDnsUsesInvalidResolver ()
86
104
{
You can’t perform that action at this time.
0 commit comments