From 6ef86b69a7d2aa07dc99a5904e2f33b7a59144d6 Mon Sep 17 00:00:00 2001 From: rwhitcroft Date: Thu, 16 Apr 2015 10:49:47 -0400 Subject: [PATCH 1/3] Fix loop spinning in HttpClient --- lib/rex/proto/http/client.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/rex/proto/http/client.rb b/lib/rex/proto/http/client.rb index 9f896689ef..a39789f24d 100644 --- a/lib/rex/proto/http/client.rb +++ b/lib/rex/proto/http/client.rb @@ -586,6 +586,8 @@ class Client begin buff = conn.get_once(-1, 1) + return resp if buff.nil? or buff.empty? + rv = resp.parse( buff || '' ) # Handle unexpected disconnects From 602e9c8df11a6a018f1c5a863f2e0be50bad9bdb Mon Sep 17 00:00:00 2001 From: rwhitcroft Date: Thu, 16 Apr 2015 16:06:16 -0400 Subject: [PATCH 2/3] Update client.rb --- lib/rex/proto/http/client.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rex/proto/http/client.rb b/lib/rex/proto/http/client.rb index a39789f24d..1a95b6b6f6 100644 --- a/lib/rex/proto/http/client.rb +++ b/lib/rex/proto/http/client.rb @@ -586,7 +586,7 @@ class Client begin buff = conn.get_once(-1, 1) - return resp if buff.nil? or buff.empty? + return resp if buff.to_s.length == 0 rv = resp.parse( buff || '' ) From 70f94bbd96a48cf944f4b375b9e780da56b06e42 Mon Sep 17 00:00:00 2001 From: rwhitcroft Date: Tue, 21 Apr 2015 11:09:17 -0400 Subject: [PATCH 3/3] break loop if socket is closed --- lib/rex/proto/http/client.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/rex/proto/http/client.rb b/lib/rex/proto/http/client.rb index 1a95b6b6f6..d15a999777 100644 --- a/lib/rex/proto/http/client.rb +++ b/lib/rex/proto/http/client.rb @@ -579,6 +579,7 @@ class Client rv = nil while ( + not conn.closed? and rv != Packet::ParseCode::Completed and rv != Packet::ParseCode::Error ) @@ -586,8 +587,6 @@ class Client begin buff = conn.get_once(-1, 1) - return resp if buff.to_s.length == 0 - rv = resp.parse( buff || '' ) # Handle unexpected disconnects