Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (24 sloc) 0.681 kB
local http = require("http")
local utils = require("utils")
local table = require("table")
http.createServer(function (req, res)
p("on_request", req)
local chunks = {}
local length = 0
req:on('data', function (chunk, len)
p("on_data", {len=len})
length = length + 1
chunks[length] = chunk
end)
req:on('end', function ()
local body = table.concat(chunks, "")
p("on_end", {total_len=#body})
body = "length = " .. tostring(#body) .. "\n"
res:writeHead(200, {
["Content-Type"] = "text/plain",
["Content-Length"] = #body
})
res:finish(body)
end)
end):listen(8080)
print("Server listening at http://localhost:8080/")
Jump to Line
Something went wrong with that request. Please try again.