@@ -33,7 +33,11 @@ __DATA__
3333 content_by_lua '
3434 local http = require "resty.http"
3535 local httpc = http.new()
36- httpc:connect("127.0.0.1", ngx.var.server_port)
36+ httpc:connect{
37+ scheme = "http",
38+ host = "127.0.0.1",
39+ port = ngx.var.server_port
40+ }
3741
3842 local res, err = httpc:request{
3943 path = "/b"
6468 content_by_lua '
6569 local http = require "resty.http"
6670 local httpc = http.new()
67- httpc:connect("127.0.0.1", ngx.var.server_port)
71+ httpc:connect{
72+ scheme = "http",
73+ host = "127.0.0.1",
74+ port = ngx.var.server_port
75+ }
6876
6977 local res, err = httpc:request{
7078 version = 1.0,
96104 content_by_lua '
97105 local http = require "resty.http"
98106 local httpc = http.new()
99- httpc:connect("127.0.0.1", ngx.var.server_port)
107+ local ok, err = httpc:connect{
108+ scheme = "http",
109+ host = "127.0.0.1",
110+ port = ngx.var.server_port
111+ }
100112
101113 local res, err = httpc:request{
102114 path = "/b"
133145 content_by_lua '
134146 local http = require "resty.http"
135147 local httpc = http.new()
136- httpc:connect("127.0.0.1", ngx.var.server_port)
148+ httpc:connect{
149+ scheme = "http",
150+ host = "127.0.0.1",
151+ port = ngx.var.server_port
152+ }
137153
138154 local res, err = httpc:request{
139155 path = "/b"
@@ -167,7 +183,11 @@ x-value
167183 content_by_lua '
168184 local http = require "resty.http"
169185 local httpc = http.new()
170- httpc:connect("127.0.0.1", ngx.var.server_port)
186+ httpc:connect{
187+ scheme = "http",
188+ host = "127.0.0.1",
189+ port = ngx.var.server_port
190+ }
171191
172192 local res, err = httpc:request{
173193 query = {
@@ -212,7 +232,11 @@ X-Header-B: 2
212232 content_by_lua '
213233 local http = require "resty.http"
214234 local httpc = http.new()
215- httpc:connect("127.0.0.1", ngx.var.server_port)
235+ httpc:connect{
236+ scheme = "http",
237+ host = "127.0.0.1",
238+ port = ngx.var.server_port
239+ }
216240
217241 local res, err = httpc:request{
218242 method = "HEAD",
@@ -245,15 +269,16 @@ GET /a
245269 content_by_lua '
246270 local http = require "resty.http"
247271
248- local res, err = http:connect("127.0.0.1", 1984)
272+ local res, err = http:connect{
273+ scheme = "http",
274+ host = "127.0.0.1",
275+ port = ngx.var.server_port
276+ }
249277 if not res then ngx.say(err) end
250278
251279 local res, err = http:set_timeout(500)
252280 if not res then ngx.say(err) end
253281
254- local res, err = http:ssl_handshake()
255- if not res then ngx.say(err) end
256-
257282 local res, err = http:set_keepalive()
258283 if not res then ngx.say(err) end
259284
@@ -272,7 +297,6 @@ not initialized
272297not initialized
273298not initialized
274299not initialized
275- not initialized
276300-- - no_error_log
277301[error]
278302[warn ]
@@ -382,8 +406,11 @@ scheme: http, host: example.com, port: 80, path: /foo/bar?a=1&b=2
382406
383407 -- Create a TCP connection and return an raw HTTP-response because
384408 -- there is no way to set an empty header value in nginx.
385- assert(httpc: connect(" 127.0.0.1" , 12345 ),
386- " connect should return positively" )
409+ assert(httpc: connect{
410+ scheme = " http" ,
411+ host = " 127.0.0.1" ,
412+ port = 12345 ,
413+ }, " connect should return positively" )
387414
388415 local res = httpc: request({ path = " /b" })
389416 if res. headers[" X-Header-Empty" ] == " " then
0 commit comments