I'm building a simple logger and ran into this:

local http = require("http")

http.createServer(function (req, res)
  local body = "Hello world\n"

  res:on("error", function(err)
    msg = tostring(err)
    print("Error while sending a response: " .. msg)
  end)

  res:on("end", function()
   -- log request / response info
    print("end")
  end)

  res:writeHead(200, {
    ["Content-Type"] = "text/plain",
    ["Content-Length"] = #body
  })
  res:finish(body)
end):listen(8080)

but the callback to res:on('end') never gets executed

Is there a way to achieve that?

cheers!

-- 
You received this message because you are subscribed to the Google Groups 
"luvit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to