Software /
code /
prosody-modules
Comparison
mod_http_upload/mod_http_upload.lua @ 1905:43fac0c2c772
mod_http_upload: Fix HEAD requests
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 13 Oct 2015 20:21:11 +0200 |
parent | 1874:8ef500508c59 |
child | 1906:5849d70bcd37 |
comparison
equal
deleted
inserted
replaced
1904:5d84b7fbe3aa | 1905:43fac0c2c772 |
---|---|
110 pending_slots[path] = nil; | 110 pending_slots[path] = nil; |
111 return 200; | 111 return 200; |
112 end | 112 end |
113 | 113 |
114 local serve_uploaded_files = module:depends("http_files").serve(storage_path); | 114 local serve_uploaded_files = module:depends("http_files").serve(storage_path); |
115 local http_server = require"net.http.server"; | |
115 | 116 |
116 local function size_only(request, data) | 117 local function size_only(response, data) |
117 request.headers.content_size = #data; | 118 if data then |
118 return 200; | 119 response.headers.content_size = #data; |
120 end | |
121 return http_server.send_response(response); | |
119 end | 122 end |
120 | 123 |
121 local function serve_head(event, path) | 124 local function serve_head(event, path) |
122 event.send = size_only; | 125 event.response.send = size_only; |
123 return serve_uploaded_files(event, path); | 126 return serve_uploaded_files(event, path); |
124 end | 127 end |
125 | 128 |
126 module:provides("http", { | 129 module:provides("http", { |
127 route = { | 130 route = { |