From 5fec13a389e6a7afcbd87419300d5eceee4a98dd Mon Sep 17 00:00:00 2001 From: HD Moore Date: Fri, 21 Oct 2011 15:41:37 +0000 Subject: [PATCH] Propogate the timeout in send_recv() down to the TCP connect call as well git-svn-id: file:///home/svn/framework3/trunk@14021 4d416f70-5f16-0410-b530-b9f4589650da --- lib/rex/proto/http/client.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/rex/proto/http/client.rb b/lib/rex/proto/http/client.rb index 49bef1b14c..90f6765015 100644 --- a/lib/rex/proto/http/client.rb +++ b/lib/rex/proto/http/client.rb @@ -288,7 +288,7 @@ class Client # # Connects to the remote server if possible. # - def connect + def connect(t = -1) # If we already have a connection and we aren't pipelining, close it. if (self.conn) if !pipelining? @@ -298,6 +298,8 @@ class Client end end + timeout = (t.nil? or t == -1) ? 0 : t + self.conn = Rex::Socket::Tcp.create( 'PeerHost' => self.hostname, 'PeerPort' => self.port.to_i, @@ -306,7 +308,8 @@ class Client 'Context' => self.context, 'SSL' => self.ssl, 'SSLVersion'=> self.ssl_version, - 'Proxies' => self.proxies + 'Proxies' => self.proxies, + 'Timeout' => timeout ) end @@ -329,7 +332,7 @@ class Client # def send_recv(req, t = -1, persist=false) @pipeline = persist - send_request(req) + send_request(req, t) res = read_response(t) res.request = req.to_s if res res @@ -338,8 +341,8 @@ class Client # # Send an HTTP request to the server # - def send_request(req) - connect + def send_request(req, t = -1) + connect(t) conn.put(req.to_s) end