@@ -18,20 +18,23 @@ describe("http.client module", function()
1818 assert .same (" string" , type (err ))
1919 assert .same (" number" , type (errno ))
2020 end )
21+ local function send_request (conn )
22+ local stream = conn :new_stream ()
23+ local req_headers = http_headers .new ()
24+ req_headers :append (" :authority" , " myauthority" )
25+ req_headers :append (" :method" , " GET" )
26+ req_headers :append (" :path" , " /" )
27+ req_headers :append (" :scheme" , conn :checktls () and " https" or " http" )
28+ assert (stream :write_headers (req_headers , true ))
29+ local res_headers = assert (stream :get_headers ())
30+ assert .same (" 200" , res_headers :get (" :status" ))
31+ end
2132 local function test_pair (client_options , server_func )
2233 local s , c = ca .assert (cs .pair ())
2334 local cq = cqueues .new ();
2435 cq :wrap (function ()
2536 local conn = assert (client .negotiate (c , client_options ))
26- local stream = conn :new_stream ()
27- local req_headers = http_headers .new ()
28- req_headers :append (" :authority" , " myauthority" )
29- req_headers :append (" :method" , " GET" )
30- req_headers :append (" :path" , " /" )
31- req_headers :append (" :scheme" , client_options .tls and " https" or " http" )
32- assert (stream :write_headers (req_headers , true ))
33- local res_headers = assert (stream :get_headers ())
34- assert .same (" 200" , res_headers :get (" :status" ))
37+ send_request (conn )
3538 end )
3639 cq :wrap (function ()
3740 s = server_func (s )
0 commit comments