Mercurial > prosody-hg
comparison plugins/mod_http_files.lua @ 5260:87f72452a893
mod_http_files: Log the error if we can't open or read a file
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 21 Dec 2012 16:10:45 +0100 |
| parents | b125892e187c |
| children | b14f02671439 |
comparison
equal
deleted
inserted
replaced
| 5259:c85c348253bd | 5260:87f72452a893 |
|---|---|
| 113 end | 113 end |
| 114 | 114 |
| 115 else | 115 else |
| 116 local f, err = open(full_path, "rb"); | 116 local f, err = open(full_path, "rb"); |
| 117 if f then | 117 if f then |
| 118 data = f:read("*a"); | 118 data, err = f:read("*a"); |
| 119 f:close(); | 119 f:close(); |
| 120 end | 120 end |
| 121 if not data then | 121 if not data then |
| 122 module:log("debug", "Could not open or read %s. Error was %s", full_path, err); | |
| 122 return 403; | 123 return 403; |
| 123 end | 124 end |
| 124 local ext = path:match("%.([^./]+)$"); | 125 local ext = path:match("%.([^./]+)$"); |
| 125 local content_type = ext and mime_map[ext]; | 126 local content_type = ext and mime_map[ext]; |
| 126 cache[path] = { data = data; content_type = content_type; etag = etag }; | 127 cache[path] = { data = data; content_type = content_type; etag = etag }; |
