Skip to content

Commit c2faeb4

Browse files
committed
Ensure partial chunks are printed on error
1 parent 02b8815 commit c2faeb4

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/resty/http.lua

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,19 +1109,21 @@ function _M.proxy_response(_, response, chunksize)
11091109

11101110
local reader = response.body_reader
11111111
repeat
1112-
local chunk, err = reader(chunksize)
1112+
local chunk, read_err = reader(chunksize)
11131113
if err then
1114-
ngx_log(ngx_ERR, err)
1115-
break
1114+
ngx_log(ngx_ERR, read_err)
11161115
end
11171116

11181117
if chunk then
1119-
local res, err = ngx_print(chunk)
1118+
local res, print_err = ngx_print(chunk)
11201119
if not res then
1121-
ngx_log(ngx_ERR, err)
1122-
break
1120+
ngx_log(ngx_ERR, print_err)
11231121
end
11241122
end
1123+
1124+
if read_err or print_err then
1125+
break
1126+
end
11251127
until not chunk
11261128
end
11271129

0 commit comments

Comments
 (0)