Diff

net/http/parser.lua @ 4712:4fc99f1b7570

net.http.parser: Handle full URLs in status line.
author Waqas Hussain <waqas20@gmail.com>
date Thu, 26 Apr 2012 20:07:13 +0500
parent 4631:fc5d3b053454
child 4716:6eeb142a8073
line wrap: on
line diff
--- 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;