Comparison

util/httpstream.lua @ 3902:a34333fcae72

util.httpstream: A little cleanup of the HTTP path.
author Waqas Hussain <waqas20@gmail.com>
date Sun, 19 Dec 2010 20:27:13 +0500
parent 3570:6ef68af9431c
child 3903:5924197aa163
comparison
equal deleted inserted replaced
3901:4447c651e6e6 3902:a34333fcae72
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