util/httpstream.lua

changeset 3920
215c0ec63816
parent 3570
6ef68af9431c
child 3903
5924197aa163
equal deleted inserted replaced
3900:e1f19f437ddd 3920:215c0ec63816
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

mercurial