Skip to content

Commit

Permalink
bugfix: Test::Nginx::Socket::Lua::Dgram: we send duplicate UDP reques…
Browse files Browse the repository at this point in the history
…ts when --- dgram_request is specified.
  • Loading branch information
agentzh committed Aug 29, 2016
1 parent c24a52b commit 83bbfa4
Showing 1 changed file with 40 additions and 19 deletions.
59 changes: 40 additions & 19 deletions lib/Test/Nginx/Socket/Lua/Dgram.pm
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,11 @@ _EOC_
_EOC_
} else {
$new_http_server_config .= <<_EOC_;
sock:send('trigger dgram req')
local data, err = sock:receive()
if not data then
sock:close()
ngx.say("receive stream response error: ", err)
return
end
local bytes, err = sock:send('trigger dgram req')
if not bytes then
ngx.say("send stream request error: ", err)
return
end
_EOC_
}

Expand All @@ -123,6 +121,15 @@ _EOC_
$block->set_value("abort", undef);
}

$new_http_server_config .= <<_EOC_;
local data, err = sock:receive()
if not data then
sock:close()
ngx.say("receive stream response error: ", err)
return
end
_EOC_

if (defined $block->response_body
|| defined $block->response_body_like
|| defined $block->dgram_response
Expand Down Expand Up @@ -161,16 +168,23 @@ _EOC_
ngx.say("send stream request error: ", err)
return
end
_EOC_
} else {
$new_http_server_config .= <<_EOC_;
local bytes, err = sock:send('trigger dgram req 2')
if not bytes then
ngx.say("send stream request error: ", err)
return
end
_EOC_
}

$new_http_server_config .= <<_EOC_;
sock:send('trigger_dgram_req2')
local data, err = sock:receive()
if not data then
ngx.say("receive stream response error: ", err)
return
end
local data, err = sock:receive()
if not data then
ngx.say("receive stream response error: ", err)
return
end
_EOC_

if (defined $block->response_body
Expand Down Expand Up @@ -205,16 +219,23 @@ _EOC_
ngx.say("send stream request error: ", err)
return
end
_EOC_
} else {
$new_http_server_config .= <<_EOC_;
local bytes, err = sock:send('trigger dgram req 3')
if not bytes then
ngx.say("send stream request error: ", err)
return
end
_EOC_
}

$new_http_server_config .= <<_EOC_;
sock:send('trigger_dgram_req3')
local data, err = sock:receive()
if not data then
ngx.say("receive stream response error: ", err)
return
end
local data, err = sock:receive()
if not data then
ngx.say("receive stream response error: ", err)
return
end
_EOC_

if (defined $block->response_body
Expand Down

0 comments on commit 83bbfa4

Please sign in to comment.