Skip to content

Commit 6fe6055

Browse files
author
siyuan
committed
add the default value of range['end']
1 parent e031afd commit 6fe6055

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/pipe/writer.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ local to_str = strutil.to_str
1010
local BLOCK_SIZE = 1024 * 1024
1111
local SOCKET_TIMEOUTS = {5 * 1000, 100 * 1000, 100 * 1000}
1212

13+
local INF = math.huge
14+
1315
local function intersect(f1, t1, f2, t2)
1416
local f, t = math.max(f1, f2), math.min(t1, t2)
1517
if f > t then
@@ -30,7 +32,14 @@ local function write_data_to_ngx(pobj, ident, opts)
3032
local recv_left, recv_right = 0, 0
3133
local from, to
3234
if range ~= nil then
33-
from, to = range['start'] + 1, range['end'] + 1
35+
from = range['start'] + 1
36+
37+
if range['end'] ~= nil then
38+
to = range['end'] + 1
39+
else
40+
to = INF
41+
end
42+
3443
if from > to then
3544
return nil, 'InvalidRange', string.format(
3645
'start: %d is greater than end: %d', from, to)

0 commit comments

Comments
 (0)