@@ -333,3 +333,41 @@ scheme: http, host: example.com, port: 80, path: /foo/bar, query: a=1&b=2
333333-- - no_error_log
334334[error]
335335[warn ]
336+
337+
338+ === TEST 11 : Parse URI fills in defaults correctly, using backwards compatible mode
339+ -- - http_config eval: $::HttpConfig
340+ -- - config
341+ location = /a {
342+ content_by_lua '
343+ local http = require("resty.http").new()
344+
345+ function test_uri(uri)
346+ local scheme, host, port, path, query = unpack(http:parse_uri(uri))
347+ ngx.say("scheme: ", scheme, ", host: ", host, ", port: ", port, ", path: ", path)
348+ end
349+
350+ test_uri("http://example.com")
351+ test_uri("http://example.com/")
352+ test_uri("https://example.com/foo/bar")
353+ test_uri("https://example.com/foo/bar?a=1&b=2")
354+ test_uri("http://example.com?a=1&b=2")
355+ test_uri("//example.com")
356+ test_uri("//example.com?a=1&b=2")
357+ test_uri("//example.com/foo/bar?a=1&b=2")
358+ ' ;
359+ }
360+ --- request
361+ GET /a
362+ -- - response_body
363+ scheme: http, host: example. com, port: 80 , path: /
364+ scheme: http, host: example. com, port: 80 , path: /
365+ scheme: https, host: example. com, port: 443 , path: / foo/ bar
366+ scheme: https, host: example. com, port: 443 , path: / foo/ bar? a= 1 & b = 2
367+ scheme: http, host: example. com, port: 80 , path: /? a= 1 & b = 2
368+ scheme: http, host: example. com, port: 80 , path: /
369+ scheme: http, host: example. com, port: 80 , path: /? a= 1 & b = 2
370+ scheme: http, host: example. com, port: 80 , path: / foo/ bar? a= 1 & b = 2
371+ -- - no_error_log
372+ [error]
373+ [warn ]
0 commit comments