Software /
code /
prosody
Comparison
plugins/mod_httpserver.lua @ 2358:e05934a5c911
mod_httpserver: Read files in binary mode; fixes issues with serving binary files.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Thu, 10 Dec 2009 16:27:17 +0500 |
parent | 2357:d978e2ae7013 |
child | 2359:0bed4af40bff |
comparison
equal
deleted
inserted
replaced
2357:d978e2ae7013 | 2358:e05934a5c911 |
---|---|
45 end | 45 end |
46 return path; | 46 return path; |
47 end | 47 end |
48 | 48 |
49 function serve_file(path) | 49 function serve_file(path) |
50 local f, err = open(http_base..path, "r"); | 50 local f, err = open(http_base..path, "rb"); |
51 if not f then return response_404; end | 51 if not f then return response_404; end |
52 local data = f:read("*a"); | 52 local data = f:read("*a"); |
53 f:close(); | 53 f:close(); |
54 local ext = path:match("%.([^.]*)$"); | 54 local ext = path:match("%.([^.]*)$"); |
55 local mime = mime_map[ext]; -- Content-Type should be nil when not known | 55 local mime = mime_map[ext]; -- Content-Type should be nil when not known |