net.http.parser: Handle full URLs in status line.
authorWaqas Hussain <waqas20@gmail.com>
Thu, 26 Apr 2012 20:07:13 +0500
changeset 4712 4fc99f1b7570
parent 4711 4ddf3ba0c749
child 4713 9c15fa5192d3
net.http.parser: Handle full URLs in status line.
net/http/parser.lua
--- 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;