moonbridge
diff example_application.lua @ 10:7e6faff049c3
Removed request.url; String in request.path does not contain a leading slash anymore; Stricter parsing of request targets
author | jbe |
---|---|
date | Thu Jan 29 16:07:56 2015 +0100 (2015-01-29) |
parents | 583e2ad140dc |
children | 0c951f8ee92b |
line diff
1.1 --- a/example_application.lua Thu Jan 29 15:14:58 2015 +0100 1.2 +++ b/example_application.lua Thu Jan 29 16:07:56 2015 +0100 1.3 @@ -61,14 +61,14 @@ 1.4 1.5 if request.method == "GET" or request.method == "HEAD" then 1.6 1.7 - if request.path == "/" then 1.8 + if request.path == "" then 1.9 request:send_status("303 See Other") 1.10 request:send_header("Location", "http://" .. request.headers_value.host .. "/example_webpage.html") 1.11 1.12 else 1.13 - local document_name = string.match(request.path, "^/(.*)$") 1.14 + local document_name = request.path 1.15 local document_extension = string.match(document_name, "%.([^.])$") 1.16 - local document = documents[string.match(request.path, "^/(.*)$")] 1.17 + local document = documents[document_name] 1.18 if document then 1.19 request:send_status("200 OK") 1.20 1.21 @@ -88,7 +88,7 @@ 1.22 1.23 elseif request.method == "POST" then 1.24 1.25 - if request.path == "/post_example" then 1.26 + if request.path == "post_example" then 1.27 local files = {} 1.28 do 1.29 local file