Mercurial > prosody-hg
comparison plugins/mod_http_files.lua @ 5252:6209b9a0244b
mod_http_files: No use in closing a file handle if we couldn't open it
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 21 Dec 2012 08:10:07 +0100 |
| parents | 13553f4132a8 |
| children | ad45612199e0 |
comparison
equal
deleted
inserted
replaced
| 5250:6d8ec8c90240 | 5252:6209b9a0244b |
|---|---|
| 104 cache[path] = { data = data, content_type = mime_map.html; hits = 0 }; | 104 cache[path] = { data = data, content_type = mime_map.html; hits = 0 }; |
| 105 response.headers.content_type = mime_map.html; | 105 response.headers.content_type = mime_map.html; |
| 106 end | 106 end |
| 107 | 107 |
| 108 else | 108 else |
| 109 local f = open(full_path, "rb"); | 109 local f, err = open(full_path, "rb"); |
| 110 data = f and f:read("*a"); | 110 if f then |
| 111 f:close(); | 111 data = f:read("*a"); |
| 112 f:close(); | |
| 113 end | |
| 112 if not data then | 114 if not data then |
| 113 return 403; | 115 return 403; |
| 114 end | 116 end |
| 115 local ext = path:match("%.([^.]*)$"); | 117 local ext = path:match("%.([^.]*)$"); |
| 116 local content_type = mime_map[ext]; | 118 local content_type = mime_map[ext]; |
