Software /
code /
prosody
Comparison
net/http/server.lua @ 11160:e9eeaefa09a7
Merge 0.11->trunk
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 13 Oct 2020 11:59:40 +0100 |
parent | 11096:dd1713862c20 |
parent | 11159:de76f566159e |
child | 11371:73f7acf8a61f |
comparison
equal
deleted
inserted
replaced
11158:3a72cb126d6c | 11160:e9eeaefa09a7 |
---|---|
329 response:done(); | 329 response:done(); |
330 end | 330 end |
331 function _M.send_response(response, body) | 331 function _M.send_response(response, body) |
332 if response.finished then return; end | 332 if response.finished then return; end |
333 body = body or response.body or ""; | 333 body = body or response.body or ""; |
334 response.headers.content_length = ("%d"):format(#body); | 334 -- Per RFC 7230, informational (1xx) and 204 (no content) should have no c-l header |
335 if response.status_code > 199 and response.status_code ~= 204 then | |
336 response.headers.content_length = ("%d"):format(#body); | |
337 end | |
335 if response.is_head_request then | 338 if response.is_head_request then |
336 return _M.send_head_response(response) | 339 return _M.send_head_response(response) |
337 end | 340 end |
338 local output = prepare_header(response); | 341 local output = prepare_header(response); |
339 t_insert(output, body); | 342 t_insert(output, body); |