Software /
code /
prosody
Comparison
net/http/server.lua @ 12831:1cdaf21584da 0.12
net.http.server: Fix #1789
Unregistering the response before sending the trailer of the chunked
transfer encoding prevents opportunistic writes from being invoked and
running this code again when, which may cause an error when closing the
file handle a second time.
Normally the file size is known, so no chuck headers are sent.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 08 Jan 2023 13:35:04 +0100 |
parent | 11527:eaff6e548f12 |
child | 12833:8cbb109ff7ec |
child | 12885:3a6dae39c70e |
comparison
equal
deleted
inserted
replaced
12829:fba795dd99c8 | 12831:1cdaf21584da |
---|---|
375 chunk = ("%x\r\n%s\r\n"):format(#chunk, chunk); | 375 chunk = ("%x\r\n%s\r\n"):format(#chunk, chunk); |
376 end | 376 end |
377 -- io.write("."); io.flush(); | 377 -- io.write("."); io.flush(); |
378 response.conn:write(chunk); | 378 response.conn:write(chunk); |
379 else | 379 else |
380 incomplete[response.conn] = nil; | |
380 if chunked then | 381 if chunked then |
381 response.conn:write("0\r\n\r\n"); | 382 response.conn:write("0\r\n\r\n"); |
382 end | 383 end |
383 -- io.write("\n"); | 384 -- io.write("\n"); |
384 if f.close then f:close(); end | 385 if f.close then f:close(); end |
385 incomplete[response.conn] = nil; | |
386 return response:done(); | 386 return response:done(); |
387 end | 387 end |
388 end | 388 end |
389 _M.write_headers(response); | 389 _M.write_headers(response); |
390 return true; | 390 return true; |