From f3b522cde8c271446567beefa27568154d0908ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6k=C3=A7en=20Eraslan?= Date: Sun, 21 Dec 2014 18:19:33 +0100 Subject: [PATCH] Try to follow 301/302 redirected URLs --- bot/utils.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bot/utils.lua b/bot/utils.lua index 043844d..ea2b8b5 100644 --- a/bot/utils.lua +++ b/bot/utils.lua @@ -33,7 +33,9 @@ end function download_to_file( url , noremove ) print("url to download: "..url) - req, c, h = http.request(url) + local ltn12 = require "ltn12" + local respbody = {} + one, c, h = http.request{url=url, sink=ltn12.sink.table(respbody), redirect=true} htype = h["content-type"] vardump(c) print("content-type: "..htype) @@ -55,7 +57,7 @@ function download_to_file( url , noremove ) end end file = io.open(file_path, "w+") - file:write(req) + file:write(table.concat(respbody)) file:close() if noremove == nil then