* Added preliminary HTTPD construct
[project/luci.git] / libs / web / luasrc / http / protocol.lua
index b0074b9..6901291 100644 (file)
@@ -517,12 +517,12 @@ function _linereader( obj, bufsz )
                __read = function() return obj:sub( _pos, _pos + bufsz - #_buf - 1 ) end
 
        -- object implements a receive() or read() function
-       elseif type(obj) == "userdata" and ( type(obj.receive) == "function" or type(obj.read) == "function" ) then
+       elseif (type(obj) == "userdata" or type(obj) == "table") and ( type(obj.receive) == "function" or type(obj.read) == "function" ) then
 
                if type(obj.read) == "function" then
-                       __read = function() return obj:read( bufsz ) end
+                       __read = function() return obj:read( bufsz - #_buf ) end
                else
-                       __read = function() return obj:receive( bufsz ) end
+                       __read = function() return obj:receive( bufsz - #_buf ) end
                end
 
        -- object is a function