Skip to content

Instantly share code, notes, and snippets.

@dvv
Created October 12, 2011 05:07
Show Gist options
  • Save dvv/1280350 to your computer and use it in GitHub Desktop.
Save dvv/1280350 to your computer and use it in GitHub Desktop.
local pipe = FS.create_read_stream(file.name, {
offset = start,
length = stop - start + 1,
})
pipe:on('data', function(chunk, len)
if cache_it then
parts[index] = chunk
index = index + 1
end
res:safe_write(chunk)
end)
pipe:on('end', function()
res:close()
if cache_it then
NUM2 = NUM2 + 1
d("cached", NUM2, {path=filename, headers=file.headers})
file.data = Table.concat(parts, '')
parts = nil
end
end)
pipe:on('error', function(err)
res:close()
parts = nil
NUM3 = NUM3 + 1
d("errored", NUM3, {path=filename, err=err})
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment