# HG changeset patch # User jbe # Date 1422545688 -3600 # Node ID 44a13f4b706f9d99863484397e548d88872986a2 # Parent 0c951f8ee92bdbafbf4cfeedf1fd95982255370e Include leading question mark in request.query diff -r 0c951f8ee92b -r 44a13f4b706f moonbridge_http.lua --- a/moonbridge_http.lua Thu Jan 29 16:09:06 2015 +0100 +++ b/moonbridge_http.lua Thu Jan 29 16:34:48 2015 +0100 @@ -115,7 +115,7 @@ -- a key value-list pairs structure that has to be -- previously obtained by calling by new_params_list(): local function read_urlencoded_form(tbl, data) - for rawkey, rawvalue in string.gmatch(data, "([^=&]*)=([^=&]*)") do + for rawkey, rawvalue in string.gmatch(data, "([^?=&]*)=([^?=&]*)") do local subtbl = tbl[decode_uri(rawkey)] subtbl[#subtbl+1] = decode_uri(rawvalue) end @@ -871,10 +871,10 @@ return error_response("400 Bad Request", "No valid host header") end -- parse request target: - request.path, request.query = string.match(target, "^/([^?]*)%??(.*)$") + request.path, request.query = string.match(target, "^/([^?]*)(.*)$") if not request.path then local host2 - host2, request.path, request.query = string.match(target, "^[Hh][Tt][Tt][Pp]://([^/?]+)/?([^?]*)%??(.*)$") + host2, request.path, request.query = string.match(target, "^[Hh][Tt][Tt][Pp]://([^/?]+)/?([^?]*)(.*)$") if host2 then if request.host ~= host2 then return error_response("400 Bad Request", "No valid host header") diff -r 0c951f8ee92b -r 44a13f4b706f reference.txt --- a/reference.txt Thu Jan 29 16:09:06 2015 +0100 +++ b/reference.txt Thu Jan 29 16:34:48 2015 +0100 @@ -305,8 +305,8 @@ ### request.query -Query part of the request target without the leading question mark, e.g. -"a=b&c=d" if the requested target is "/index.html?a=b&c=d". The data is +Query part of the request target including the leading question mark, e.g. +"?a=b&c=d" if the requested target is "/index.html?a=b&c=d". The data is automatically parsed and made available through request.get_params and request.get_params_list.