Diff

net/http/parser.lua @ 6386:f942cf2a9a03

net.http.parser: Support status code 101 and allow handling of the received data by someone else
author Matthew Wild <mwild1@gmail.com>
date Wed, 03 Sep 2014 18:49:41 +0100
parent 5477:50cbea68586f
child 6522:46cf369d3eb5
line wrap: on
line diff
--- a/net/http/parser.lua	Tue Sep 02 17:23:44 2014 +0100
+++ b/net/http/parser.lua	Wed Sep 03 18:49:41 2014 +0100
@@ -140,7 +140,11 @@
 								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;