diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-01-18 00:04:20 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-01-18 00:04:20 +0000 |
commit | c8d58798f0b0c789df5c566494112f81ac302432 (patch) | |
tree | 40c52eab0a4bf92636ebe13027d165f0b8452bb1 /src/http.lua | |
parent | 02ef4e7daae6bef629dcb568052755fb85ed2efc (diff) | |
download | luasocket-c8d58798f0b0c789df5c566494112f81ac302432.tar.gz luasocket-c8d58798f0b0c789df5c566494112f81ac302432.tar.bz2 luasocket-c8d58798f0b0c789df5c566494112f81ac302432.zip |
Trying to get connect-with-timeout to work. Darwin works...
Diffstat (limited to 'src/http.lua')
-rw-r--r-- | src/http.lua | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/http.lua b/src/http.lua index 1925c68..2fc9e87 100644 --- a/src/http.lua +++ b/src/http.lua | |||
@@ -549,10 +549,16 @@ function request_cb(reqt, respt) | |||
549 | reqt.headers = fill_headers(reqt.headers, parsed) | 549 | reqt.headers = fill_headers(reqt.headers, parsed) |
550 | -- try to connect to server | 550 | -- try to connect to server |
551 | local sock | 551 | local sock |
552 | sock, respt.error = socket.connect(parsed.host, parsed.port) | 552 | sock, respt.error = socket.tcp() |
553 | if not sock then return respt end | 553 | if not sock then return respt end |
554 | -- set connection timeout so that we do not hang forever | 554 | -- set connection timeout so that we do not hang forever |
555 | sock:settimeout(TIMEOUT) | 555 | sock:settimeout(TIMEOUT) |
556 | local ret | ||
557 | ret, respt.error = sock:connect(parsed.host, parsed.port) | ||
558 | if not ret then | ||
559 | sock:close() | ||
560 | return respt | ||
561 | end | ||
556 | -- send request message | 562 | -- send request message |
557 | respt.error = send_request(sock, reqt.method, | 563 | respt.error = send_request(sock, reqt.method, |
558 | request_uri(parsed), reqt.headers, reqt.body_cb) | 564 | request_uri(parsed), reqt.headers, reqt.body_cb) |