Comparison

net/http/parser.lua @ 5462:3ecae471d9dd

net.http.parser: Convert status_code to a number before trying to compare it to numbers
author Matthew Wild <mwild1@gmail.com>
date Thu, 11 Apr 2013 19:58:53 +0100
parent 5461:67b674f6a299
child 5463:111953bfe767
comparison
equal deleted inserted replaced
5461:67b674f6a299 5462:3ecae471d9dd
63 headers[key] = headers[key] and headers[key]..","..val or val; 63 headers[key] = headers[key] and headers[key]..","..val or val;
64 else 64 else
65 first_line = line; 65 first_line = line;
66 if client then 66 if client then
67 httpversion, status_code, reason_phrase = line:match("^HTTP/(1%.[01]) (%d%d%d) (.*)$"); 67 httpversion, status_code, reason_phrase = line:match("^HTTP/(1%.[01]) (%d%d%d) (.*)$");
68 status_code = tonumber(status_code);
68 if not status_code then error = true; return error_cb("invalid-status-line"); end 69 if not status_code then error = true; return error_cb("invalid-status-line"); end
69 have_body = not 70 have_body = not
70 ( (options_cb and options_cb().method == "HEAD") 71 ( (options_cb and options_cb().method == "HEAD")
71 or (status_code == 204 or status_code == 304 or status_code == 301) 72 or (status_code == 204 or status_code == 304 or status_code == 301)
72 or (status_code >= 100 and status_code < 200) ); 73 or (status_code >= 100 and status_code < 200) );