X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=net%2Fhttp%2Fparser.lua;h=2545b5ac41457b88e345f5a6743650052e43ff40;hb=2c2cf38d1ac841f960da7d36f71fed1d1750ac3f;hp=c760a0a44453850a202c962a434fe15bae715d9e;hpb=adad4b03da5527185e9f20a7bd2032eaf6d093a5;p=prosody.git diff --git a/net/http/parser.lua b/net/http/parser.lua index c760a0a4..2545b5ac 100644 --- a/net/http/parser.lua +++ b/net/http/parser.lua @@ -77,6 +77,7 @@ function httpstream.new(success_cb, error_cb, parser_type, options_cb) end end end + if not first_line then error = true; return error_cb("invalid-status-line"); end len = tonumber(headers["content-length"]); -- TODO check for invalid len if client then -- FIXME handle '100 Continue' response (by skipping it) @@ -91,7 +92,15 @@ 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); + if not(parsed_url and parsed_url.path) then error = true; return error_cb("invalid-url"); end + end path = preprocess_path(parsed_url.path); headers.host = parsed_url.host or headers.host;