Changeset

11045:8c6bace13229

util.dbuffer: Fix :sub() not working with partially-consumed chunks (thanks Zash for test case) This also appears to fix some bugs with chunk-encoded streams in net.http.parser.
author Matthew Wild <mwild1@gmail.com>
date Mon, 24 Aug 2020 16:18:13 +0100
parents 11044:7b720a815519
children 11046:64713f21ff0e
files spec/util_dbuffer_spec.lua util/dbuffer.lua
diffstat 2 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/spec/util_dbuffer_spec.lua	Mon Aug 24 17:07:37 2020 +0200
+++ b/spec/util_dbuffer_spec.lua	Mon Aug 24 16:18:13 2020 +0100
@@ -67,7 +67,7 @@
 			assert.equals("hello", b:sub(1, 5));
 		end);
 
-		pending("works after discard", function ()
+		it("works after discard", function ()
 			local b = dbuffer.new(256);
 			assert.truthy(b:write("foo"));
 			assert.truthy(b:write("bar"));
--- a/util/dbuffer.lua	Mon Aug 24 17:07:37 2020 +0200
+++ b/util/dbuffer.lua	Mon Aug 24 16:18:13 2020 +0100
@@ -123,7 +123,7 @@
 
 	self:collapse(j);
 
-	return self.items:peek():sub(i, j);
+	return self.items:peek():sub(self.front_consumed+1):sub(i, j);
 end
 
 function dbuffer_methods:byte(i, j)