Mercurial > prosody-hg
comparison net/http/server.lua @ 11159:de76f566159e 0.11
net.http.server: Don't send Content-Length on 1xx/204 responses, per RFC (fixes #1596)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 13 Oct 2020 11:55:28 +0100 |
| parents | f4215f8baa5d |
| children | e9eeaefa09a7 |
comparison
equal
deleted
inserted
replaced
| 11157:413bd21ba449 | 11159:de76f566159e |
|---|---|
| 293 end | 293 end |
| 294 _M.prepare_header = prepare_header; | 294 _M.prepare_header = prepare_header; |
| 295 function _M.send_response(response, body) | 295 function _M.send_response(response, body) |
| 296 if response.finished then return; end | 296 if response.finished then return; end |
| 297 body = body or response.body or ""; | 297 body = body or response.body or ""; |
| 298 response.headers.content_length = #body; | 298 -- Per RFC 7230, informational (1xx) and 204 (no content) should have no c-l header |
| 299 if response.status_code > 199 and response.status_code ~= 204 then | |
| 300 response.headers.content_length = #body; | |
| 301 end | |
| 299 local output = prepare_header(response); | 302 local output = prepare_header(response); |
| 300 t_insert(output, body); | 303 t_insert(output, body); |
| 301 response.conn:write(t_concat(output)); | 304 response.conn:write(t_concat(output)); |
| 302 response:done(); | 305 response:done(); |
| 303 end | 306 end |
