Skip to content

Commit 001e312

Browse files
committed
Merge branch 'zenedge-allow_custom_request_body_socket'
2 parents 9e6e418 + 56d065a commit 001e312

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

lib/resty/http.lua

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ function _M.read_response(self, params)
573573

574574

575575
local res_headers, err = _receive_headers(sock)
576-
if not res_headers then
576+
if not res_headers then
577577
return nil, err
578578
end
579579

@@ -726,19 +726,22 @@ function _M.request_uri(self, uri, params)
726726
end
727727

728728

729-
function _M.get_client_body_reader(self, chunksize)
729+
function _M.get_client_body_reader(self, chunksize, sock)
730730
local chunksize = chunksize or 65536
731-
local ok, sock, err = pcall(ngx_req_socket)
731+
if not sock then
732+
local ok, err
733+
ok, sock, err = pcall(ngx_req_socket)
732734

733-
if not ok then
734-
return nil, sock -- pcall err
735-
end
735+
if not ok then
736+
return nil, sock -- pcall err
737+
end
736738

737-
if not sock then
738-
if err == "no body" then
739-
return nil
740-
else
741-
return nil, err
739+
if not sock then
740+
if err == "no body" then
741+
return nil
742+
else
743+
return nil, err
744+
end
742745
end
743746
end
744747

0 commit comments

Comments
 (0)