Skip to content

Commit fee368c

Browse files
committed
More accurate error handling for the client_body_reader
1 parent 53a0de6 commit fee368c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/resty/http.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,10 +706,13 @@ end
706706

707707
function _M.get_client_body_reader(self, chunksize)
708708
local chunksize = chunksize or 65536
709-
local ok, sock = pcall(ngx_req_socket)
709+
local ok, sock, err = pcall(ngx_req_socket)
710710

711711
if not ok then
712-
local err = sock
712+
return nil, sock -- pcall err
713+
end
714+
715+
if not sock then
713716
if err == "no body" then
714717
return nil
715718
else
@@ -742,6 +745,11 @@ end
742745

743746

744747
function _M.proxy_response(self, response, chunksize)
748+
if not response then
749+
ngx_log(ngx_ERR, "no response provided")
750+
return
751+
end
752+
745753
ngx.status = response.status
746754

747755
-- Filter out hop-by-hop headeres

0 commit comments

Comments
 (0)