net.http.parser: Support status code 101 and allow handling of the received data...
authorMatthew Wild <mwild1@gmail.com>
Wed, 3 Sep 2014 17:49:41 +0000 (18:49 +0100)
committerMatthew Wild <mwild1@gmail.com>
Wed, 3 Sep 2014 17:49:41 +0000 (18:49 +0100)
net/http/parser.lua

index f9e6cea0607d1c74f3d26203fad8374370a344d1..d896dff4c6749b589b8e0947b52e08c4d2b03c06 100644 (file)
@@ -140,7 +140,11 @@ function httpstream.new(success_cb, error_cb, parser_type, options_cb)
                                                                break;
                                                        end
                                                elseif len and #buf >= len then
-                                                       packet.body, buf = buf:sub(1, len), buf:sub(len + 1);
+                                                       if packet.code == 101 then
+                                                               packet.body, buf = buf, ""
+                                                       else
+                                                               packet.body, buf = buf:sub(1, len), buf:sub(len + 1);
+                                                       end
                                                        state = nil; success_cb(packet);
                                                else
                                                        break;