Skip to content

Commit 398fe5c

Browse files
committed
Test parse_uri errors when uri is malformed
1 parent 383c4b5 commit 398fe5c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

t/01-basic.t

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ GET /a
245245
content_by_lua '
246246
local http = require "resty.http"
247247
248+
local res, err = http:connect("127.0.0.1", 1984)
249+
if not res then ngx.say(err) end
250+
248251
local res, err = http:set_timeout(500)
249252
if not res then ngx.say(err) end
250253
@@ -269,6 +272,26 @@ not initialized
269272
not initialized
270273
not initialized
271274
not initialized
275+
not initialized
276+
--- no_error_log
277+
[error]
278+
[warn]
279+
280+
281+
=== TEST 9: Parse URI errors if malformed
282+
--- http_config eval: $::HttpConfig
283+
--- config
284+
location = /a {
285+
content_by_lua '
286+
local http = require("resty.http").new()
287+
local parts, err = http:parse_uri("http:///example.com")
288+
if not parts then ngx.say(err) end
289+
';
290+
}
291+
--- request
292+
GET /a
293+
--- response_body
294+
bad uri: http:///example.com
272295
--- no_error_log
273296
[error]
274297
[warn]

0 commit comments

Comments
 (0)