net.http: Close connection when invalid status line is received from the server

Fri, 19 Feb 2010 03:21:50 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 19 Feb 2010 03:21:50 +0000
changeset 2672
215d448d69d0
parent 2671
2dd69e1f7055
child 2673
61ae351c19b5

net.http: Close connection when invalid status line is received from the server

net/http.lua file | annotate | diff | comparison | revisions
--- a/net/http.lua	Fri Feb 19 03:21:20 2010 +0000
+++ b/net/http.lua	Fri Feb 19 03:21:50 2010 +0000
@@ -107,7 +107,10 @@
 		local http, code, text, linelen = data:match("^HTTP/(%S+) (%d+) (.-)\r\n()", startpos);
 		code = tonumber(code);
 		if not code then
-			return request.callback("invalid-status-line", 0, request);
+			log("warn", "Invalid HTTP status line, telling callback then closing");
+			local ret = request.callback("invalid-status-line", 0, request);
+			destroy_request(request);
+			return ret;
 		end
 		
 		request.code, request.responseversion = code, http;

mercurial