lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


RJP Computing wrote:
I tested this and the server doesn't support it. Any other way to use a sink and then cancel after enough chunks have been received? Does anyone have an example of this? Thanks.


Maybe something along these lines:

require"luarocks.require"
local http = require "socket.http"

print(http.request{
  url = "http://lua-users.org/wiki/FiltersSourcesAndSinks";,
  sink = function(chunk, err)
		if chunk then
			print("got a chunk of length", #chunk)
-- process chunk and return nil when you don't want to process more chunks
		end
		return 1
  end
})

--
Regards,
Ignacio Burgueño