Comparison

net/http.lua @ 2672:215d448d69d0

net.http: Close connection when invalid status line is received from the server
author Matthew Wild <mwild1@gmail.com>
date Fri, 19 Feb 2010 03:21:50 +0000
parent 2671:2dd69e1f7055
child 2673:61ae351c19b5
comparison
equal deleted inserted replaced
2671:2dd69e1f7055 2672:215d448d69d0
105 elseif request.state == "status" then 105 elseif request.state == "status" then
106 print("Reading status...") 106 print("Reading status...")
107 local http, code, text, linelen = data:match("^HTTP/(%S+) (%d+) (.-)\r\n()", startpos); 107 local http, code, text, linelen = data:match("^HTTP/(%S+) (%d+) (.-)\r\n()", startpos);
108 code = tonumber(code); 108 code = tonumber(code);
109 if not code then 109 if not code then
110 return request.callback("invalid-status-line", 0, request); 110 log("warn", "Invalid HTTP status line, telling callback then closing");
111 local ret = request.callback("invalid-status-line", 0, request);
112 destroy_request(request);
113 return ret;
111 end 114 end
112 115
113 request.code, request.responseversion = code, http; 116 request.code, request.responseversion = code, http;
114 117
115 if request.onlystatus then 118 if request.onlystatus then