Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local host = "www.novaember.com"
- local file = "/php/br.php"
- require("socket.http")
- local c, count, str = nil, 0, ""
- function love.load()
- c = assert(socket.connect(host, 80))
- c:send("GET "..file.." HTTP/1.1\r\nHost: "..host.."\r\nAccept: *\r\n\r\n")
- while true do
- local s, status = receive(c)
- print("Length: "..string.len(s or ""))
- print("Status: "..(status or "Nothing"))
- print(s)
- print("End message.")
- count = count + string.len(s or "")
- str = str .. (s or "")
- if status == "closed" then break end
- end
- c:close()
- print(file, count)
- end
- function receive (connection)
- local s, status = connection:receive("*a")
- if status == "timeout" then
- coroutine.yield(connection)
- end
- return s, status
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement