Advertisement
Darkwater

Untitled

Nov 15th, 2011
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1. local host = "www.novaember.com"
  2. local file = "/php/br.php"
  3.  
  4. require("socket.http")
  5.  
  6. local c, count, str = nil, 0, ""
  7.  
  8. function love.load()
  9.     c = assert(socket.connect(host, 80))
  10.     c:send("GET "..file.." HTTP/1.1\r\nHost: "..host.."\r\nAccept: *\r\n\r\n")
  11.     while true do
  12.         local s, status = receive(c)
  13.         print("Length: "..string.len(s or ""))
  14.         print("Status: "..(status or "Nothing"))
  15.         print(s)
  16.         print("End message.")
  17.         count = count + string.len(s or "")
  18.         str = str .. (s or "")
  19.         if status == "closed" then break end
  20.     end
  21.     c:close()
  22.     print(file, count)
  23. end
  24.  
  25. function receive (connection)
  26.     local s, status = connection:receive("*a")
  27.     if status == "timeout" then
  28.         coroutine.yield(connection)
  29.     end
  30.     return s, status
  31. end
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement