login

<     >

2022-02-27 18:46:30 (UTC-03:00)

Marcel Rodrigues <marcelgmr@gmail.com>

support 303 redirection

diff --git a/src/http.lua b/src/http.lua
index 2c82324..59679d3 100644
--- a/src/http.lua
+++ b/src/http.lua
@@ -66,13 +66,17 @@ local function build_cookie_data(cookies)
 end
 
 local function build_response(data, status, reason, cookies)
+    local header = ""
     if status == nil then
         status = 200
         reason = "OK"
+    elseif status == 303 then
+        reason = reason or "See Other"
+        header = "Location: " .. data .. "\n"
     end
-    local cookie_data = build_cookie_data(cookies)
+    header = header .. build_cookie_data(cookies)
     local fmt = "HTTP/1.1 %03d %s\r\n%s\r\n%s"
-    return fmt:format(status, reason, cookie_data, data)
+    return fmt:format(status, reason, header, data)
 end
 
 local HTTP = {}