Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
Determine nreqt.host is a domain name or a ip address,when it's a domain name,resolve it.
  • Loading branch information
Hevienz committed May 19, 2014
1 parent a6bb8a9 commit 1215215
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/resty/http.lua
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,15 @@ function request(self, reqt)

sock:settimeout(nreqt.timeout)

local address=resolve(nreqt.host)
-- determine nreqt.host is a domain name or a ip address
local is_ip=string.match(nreqt.host,"%d+%.%d+%.%d+%.%d+")
local address=nil
if is_ip then
address=nreqt.host
else
address=resolve(nreqt.host)
end

-- connect
ok, err = sock:connect(address, nreqt.port)
if err then
Expand Down

0 comments on commit 1215215

Please sign in to comment.