From 0b8a61a536a6f78fbe889979510297969d6a5f4e Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Thu, 5 Mar 2009 23:52:54 +0000 Subject: httpclient: callback can abort download --- libs/httpclient/luasrc/httpclient/receiver.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/httpclient/luasrc/httpclient/receiver.lua b/libs/httpclient/luasrc/httpclient/receiver.lua index c977d064b..852a10db2 100644 --- a/libs/httpclient/luasrc/httpclient/receiver.lua +++ b/libs/httpclient/luasrc/httpclient/receiver.lua @@ -203,7 +203,11 @@ function request_to_file(uri, target, options, cbs) end if cbs.on_header then - cbs.on_header(file, code, resp) + if cbs.on_header(file, code, resp) == false then + file:close() + sock:close() + return true + end end local chunked = resp.headers["Transfer-Encoding"] == "chunked" -- cgit v1.2.3