moonbridge
changeset 12:44a13f4b706f
Include leading question mark in request.query
author | jbe |
---|---|
date | Thu Jan 29 16:34:48 2015 +0100 (2015-01-29) |
parents | 0c951f8ee92b |
children | 96b6c31d72e3 |
files | moonbridge_http.lua reference.txt |
line diff
1.1 --- a/moonbridge_http.lua Thu Jan 29 16:09:06 2015 +0100 1.2 +++ b/moonbridge_http.lua Thu Jan 29 16:34:48 2015 +0100 1.3 @@ -115,7 +115,7 @@ 1.4 -- a key value-list pairs structure that has to be 1.5 -- previously obtained by calling by new_params_list(): 1.6 local function read_urlencoded_form(tbl, data) 1.7 - for rawkey, rawvalue in string.gmatch(data, "([^=&]*)=([^=&]*)") do 1.8 + for rawkey, rawvalue in string.gmatch(data, "([^?=&]*)=([^?=&]*)") do 1.9 local subtbl = tbl[decode_uri(rawkey)] 1.10 subtbl[#subtbl+1] = decode_uri(rawvalue) 1.11 end 1.12 @@ -871,10 +871,10 @@ 1.13 return error_response("400 Bad Request", "No valid host header") 1.14 end 1.15 -- parse request target: 1.16 - request.path, request.query = string.match(target, "^/([^?]*)%??(.*)$") 1.17 + request.path, request.query = string.match(target, "^/([^?]*)(.*)$") 1.18 if not request.path then 1.19 local host2 1.20 - host2, request.path, request.query = string.match(target, "^[Hh][Tt][Tt][Pp]://([^/?]+)/?([^?]*)%??(.*)$") 1.21 + host2, request.path, request.query = string.match(target, "^[Hh][Tt][Tt][Pp]://([^/?]+)/?([^?]*)(.*)$") 1.22 if host2 then 1.23 if request.host ~= host2 then 1.24 return error_response("400 Bad Request", "No valid host header")
2.1 --- a/reference.txt Thu Jan 29 16:09:06 2015 +0100 2.2 +++ b/reference.txt Thu Jan 29 16:34:48 2015 +0100 2.3 @@ -305,8 +305,8 @@ 2.4 2.5 ### request.query 2.6 2.7 -Query part of the request target without the leading question mark, e.g. 2.8 -"a=b&c=d" if the requested target is "/index.html?a=b&c=d". The data is 2.9 +Query part of the request target including the leading question mark, e.g. 2.10 +"?a=b&c=d" if the requested target is "/index.html?a=b&c=d". The data is 2.11 automatically parsed and made available through request.get_params and 2.12 request.get_params_list. 2.13