From b0b093e7264da1a620a2f4e9101e1b676ea1db0e Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Thu, 26 Apr 2012 20:07:13 +0500 Subject: net.http.parser: Handle full URLs in status line. --- net/http/parser.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'net/http/parser.lua') diff --git a/net/http/parser.lua b/net/http/parser.lua index c98c75af..fdcb8ebb 100644 --- a/net/http/parser.lua +++ b/net/http/parser.lua @@ -53,7 +53,6 @@ function httpstream.new(success_cb, error_cb, parser_type, options_cb) 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 @@ function httpstream.new(success_cb, error_cb, parser_type, options_cb) 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; -- cgit v1.2.3