net.http.parser: Skip url.parse when we don't have a full URL (also fixes traceback...
authorWaqas Hussain <waqas20@gmail.com>
Fri, 21 Dec 2012 08:37:39 +0000 (13:37 +0500)
committerWaqas Hussain <waqas20@gmail.com>
Fri, 21 Dec 2012 08:37:39 +0000 (13:37 +0500)
net/http/parser.lua

index c760a0a44453850a202c962a434fe15bae715d9e..b53dfa4ede3381b96068f95038b9969845b00418 100644 (file)
@@ -91,7 +91,14 @@ function httpstream.new(success_cb, error_cb, parser_type, options_cb)
                                                        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;