net.http.parser: Skip url.parse when we don't have a full URL (also fixes traceback on paths starting with '//').
authorWaqas Hussain <waqas20@gmail.com>
Fri, 21 Dec 2012 13:37:39 +0500
changeset 5259 c85c348253bd
parent 5257 b125892e187c
child 5260 87f72452a893
net.http.parser: Skip url.parse when we don't have a full URL (also fixes traceback on paths starting with '//').
net/http/parser.lua
--- a/net/http/parser.lua	Fri Dec 21 09:04:02 2012 +0100
+++ b/net/http/parser.lua	Fri Dec 21 13:37:39 2012 +0500
@@ -91,7 +91,14 @@
 							responseheaders = headers;
 						};
 					else
-						local parsed_url = url_parse(path);
+						local parsed_url;
+						if path:byte() == 47 then -- starts with /
+							local _path, _query = path:match("([^?]*).?(.*)");
+							if _query == "" then _query = nil; end
+							parsed_url = { path = _path, query = _query };
+						else
+							parsed_url = url_parse(path);
+						end
 						path = preprocess_path(parsed_url.path);
 						headers.host = parsed_url.host or headers.host;