libs/http: Fixed default sink for unknown data
authorSteven Barth <steven@midlink.org>
Fri, 22 Aug 2008 20:33:48 +0000 (20:33 +0000)
committerSteven Barth <steven@midlink.org>
Fri, 22 Aug 2008 20:33:48 +0000 (20:33 +0000)
libs/http/luasrc/http/protocol.lua

index 6e2ae29e31b109dc1a49ad8cc3d0fe4d52aa77ed..c80380e97d437e54f6280658a60f2db425375a73 100644 (file)
@@ -638,16 +638,17 @@ function parse_message_body( src, msg, filecb )
                        msg.content = ""
                        msg.content_length = 0
 
-                       sink = function( chunk )
-                               if ( msg.content_length + #chunk ) <= HTTP_MAX_CONTENT then
-
-                                       msg.content        = msg.content        .. chunk
-                                       msg.content_length = msg.content_length + #chunk
-
-                                       return true
-                               else
-                                       return nil, "POST data exceeds maximum allowed length"
+                       sink = function( chunk, err )
+                               if chunk then
+                                       if ( msg.content_length + #chunk ) <= HTTP_MAX_CONTENT then
+                                               msg.content        = msg.content        .. chunk
+                                               msg.content_length = msg.content_length + #chunk
+                                               return true
+                                       else
+                                               return nil, "POST data exceeds maximum allowed length"
+                                       end
                                end
+                               return true
                        end
                end