net.http.parser: Handle full URLs in status line.
--- a/net/http/parser.lua Thu Apr 26 15:16:29 2012 +0100
+++ b/net/http/parser.lua Thu Apr 26 20:07:13 2012 +0500
@@ -53,7 +53,6 @@
else
method, path, httpversion = line:match("^(%w+) (%S+) HTTP/(1%.[01])$");
if not method then error = true; return error_cb("invalid-status-line"); end
- path = path:gsub("^//+", "/"); -- TODO parse url more
end
end
end
@@ -71,6 +70,12 @@
responseheaders = headers;
};
else
+ -- path normalization
+ if path:match("^https?://") then
+ headers.host, path = path:match("^https?://([^/]*)(.*)");
+ end
+ path = path:gsub("^//+", "/"); -- TODO parse url more
+
len = len or 0;
packet = {
method = method;