This repository was archived by the owner on Jan 13, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 9
9
import requests
10
10
import threading
11
11
import time
12
+ import socket
12
13
import hyper
13
14
import hyper .http11 .connection
14
15
import pytest
25
26
REQUEST_CODES , REQUEST_CODES_LENGTH
26
27
)
27
28
from hyper .http20 .exceptions import ConnectionError , StreamResetError
29
+ from hyper .tls import wrap_socket
28
30
from server import SocketLevelTest
29
31
30
32
# Turn off certificate verification for the tests.
@@ -74,6 +76,31 @@ def receive_preamble(sock):
74
76
return
75
77
76
78
79
+ class TestBasicSocketManipulation (SocketLevelTest ):
80
+ # These aren't HTTP/2 tests, but it doesn't hurt to leave it.
81
+ h2 = True
82
+
83
+ def test_connection_string (self ):
84
+ self .set_up ()
85
+ evt = threading .Event ()
86
+
87
+ def socket_handler (listener ):
88
+ sock = listener .accept ()[0 ]
89
+
90
+ evt .wait (5 )
91
+ sock .close ()
92
+
93
+ self ._start_server (socket_handler )
94
+ s = socket .create_connection ((self .host , self .port ))
95
+ s , proto = wrap_socket (s , "localhost" , force_proto = b"test" )
96
+ s .close ()
97
+ evt .set ()
98
+
99
+ assert proto == b"test"
100
+
101
+ self .tear_down ()
102
+
103
+
77
104
class TestHyperIntegration (SocketLevelTest ):
78
105
# These are HTTP/2 tests.
79
106
h2 = True
You can’t perform that action at this time.
0 commit comments