Changeset

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
parents 4711:4ddf3ba0c749
children 4713:9c15fa5192d3
files net/http/parser.lua
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
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;