44 while true do |
44 while true do |
45 -- read status line |
45 -- read status line |
46 local status_line = readline(); |
46 local status_line = readline(); |
47 local method, path, httpversion = status_line:match("^(%S+)%s+(%S+)%s+HTTP/(%S+)$"); |
47 local method, path, httpversion = status_line:match("^(%S+)%s+(%S+)%s+HTTP/(%S+)$"); |
48 if not method then coroutine.yield("invalid-status-line"); end |
48 if not method then coroutine.yield("invalid-status-line"); end |
49 -- TODO parse url |
49 path = path:gsub("^//+", "/"); -- TODO parse url more |
50 local headers = readheaders(); |
50 local headers = readheaders(); |
51 |
51 |
52 -- read body |
52 -- read body |
53 local len = tonumber(headers["content-length"]); |
53 local len = tonumber(headers["content-length"]); |
54 len = len or 0; -- TODO check for invalid len |
54 len = len or 0; -- TODO check for invalid len |