Software /
code /
prosody
Comparison
plugins/mod_http_files.lua @ 4672:e17fe44146b0
mod_http_files: Rename argument to reflect what it actually is
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 24 Apr 2012 00:17:15 +0200 |
parent | 4671:7e4c1fb44dd7 |
child | 4700:63386138e393 |
comparison
equal
deleted
inserted
replaced
4671:7e4c1fb44dd7 | 4672:e17fe44146b0 |
---|---|
45 end | 45 end |
46 end | 46 end |
47 return path; | 47 return path; |
48 end | 48 end |
49 | 49 |
50 function serve_file(request, path) | 50 function serve_file(event, path) |
51 local response = request.response; | 51 local response = event.response; |
52 path = path and preprocess_path(path); | 52 path = path and preprocess_path(path); |
53 if not path then | 53 if not path then |
54 response.status = 400; | 54 response.status = 400; |
55 return response:send(response_400); | 55 return response:send(response_400); |
56 end | 56 end |
57 local full_path = http_base..path; | 57 local full_path = http_base..path; |
58 if stat(full_path, "mode") == "directory" then | 58 if stat(full_path, "mode") == "directory" then |
59 if stat(full_path.."/index.html", "mode") == "file" then | 59 if stat(full_path.."/index.html", "mode") == "file" then |
60 return serve_file(request, path.."/index.html"); | 60 return serve_file(event, path.."/index.html"); |
61 end | 61 end |
62 response.status = 403; | 62 response.status = 403; |
63 return response:send(response_403); | 63 return response:send(response_403); |
64 end | 64 end |
65 local f, err = open(full_path, "rb"); | 65 local f, err = open(full_path, "rb"); |