tests: added a passing test case for connecting to IPv6 addresses via cosockets.
This commit is contained in:
Родитель
4323f3bc13
Коммит
c9128e50f9
|
@ -5,7 +5,7 @@ use Test::Nginx::Socket::Lua;
|
||||||
|
|
||||||
repeat_each(2);
|
repeat_each(2);
|
||||||
|
|
||||||
plan tests => repeat_each() * 169;
|
plan tests => repeat_each() * 172;
|
||||||
|
|
||||||
our $HtmlDir = html_dir;
|
our $HtmlDir = html_dir;
|
||||||
|
|
||||||
|
@ -3220,3 +3220,77 @@ close: 1 nil
|
||||||
lua socket tcp_nodelay
|
lua socket tcp_nodelay
|
||||||
[error]
|
[error]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
=== TEST 54: IPv6
|
||||||
|
--- http_config
|
||||||
|
server_tokens off;
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen [::1]:$TEST_NGINX_PORT;
|
||||||
|
|
||||||
|
location /foo {
|
||||||
|
content_by_lua 'ngx.say("foo")';
|
||||||
|
more_clear_headers Date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--- config
|
||||||
|
location /t {
|
||||||
|
#set $port 5000;
|
||||||
|
set $port $TEST_NGINX_SERVER_PORT;
|
||||||
|
|
||||||
|
content_by_lua '
|
||||||
|
local sock = ngx.socket.tcp()
|
||||||
|
local port = ngx.var.port
|
||||||
|
local ok, err = sock:connect("[::1]", port)
|
||||||
|
if not ok then
|
||||||
|
ngx.say("failed to connect: ", err)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
ngx.say("connected: ", ok)
|
||||||
|
|
||||||
|
local req = "GET /foo HTTP/1.0\\r\\nHost: localhost\\r\\nConnection: close\\r\\n\\r\\n"
|
||||||
|
-- req = "OK"
|
||||||
|
|
||||||
|
local bytes, err = sock:send(req)
|
||||||
|
if not bytes then
|
||||||
|
ngx.say("failed to send request: ", err)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
ngx.say("request sent: ", bytes)
|
||||||
|
|
||||||
|
while true do
|
||||||
|
local line, err, part = sock:receive()
|
||||||
|
if line then
|
||||||
|
ngx.say("received: ", line)
|
||||||
|
|
||||||
|
else
|
||||||
|
ngx.say("failed to receive a line: ", err, " [", part, "]")
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
ok, err = sock:close()
|
||||||
|
ngx.say("close: ", ok, " ", err)
|
||||||
|
';
|
||||||
|
}
|
||||||
|
|
||||||
|
--- request
|
||||||
|
GET /t
|
||||||
|
--- response_body
|
||||||
|
connected: 1
|
||||||
|
request sent: 57
|
||||||
|
received: HTTP/1.1 200 OK
|
||||||
|
received: Server: nginx
|
||||||
|
received: Content-Type: text/plain
|
||||||
|
received: Content-Length: 4
|
||||||
|
received: Connection: close
|
||||||
|
received:
|
||||||
|
received: foo
|
||||||
|
failed to receive a line: closed []
|
||||||
|
close: 1 nil
|
||||||
|
--- no_error_log
|
||||||
|
[error]
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ force=$2
|
||||||
#--without-http_referer_module \
|
#--without-http_referer_module \
|
||||||
|
|
||||||
time ngx-build $force $version \
|
time ngx-build $force $version \
|
||||||
|
--with-ipv6 \
|
||||||
--with-cc-opt="-I$PCRE_INC" \
|
--with-cc-opt="-I$PCRE_INC" \
|
||||||
--with-http_realip_module \
|
--with-http_realip_module \
|
||||||
--with-http_ssl_module \
|
--with-http_ssl_module \
|
||||||
|
|
Загрузка…
Ссылка в новой задаче