Skip to content

Commit

Permalink
http_proxy: use ngx.req.get_body_data to read the body
Browse files Browse the repository at this point in the history
We cannot use resty.http's .get_client_body_reader().

The result of that is nil, and it results in a time-out in
some cases. Possibly because of this:
ledgetech/lua-resty-http#31
  • Loading branch information
davidor committed Jan 14, 2019
1 parent 7cbfdd4 commit 791301a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion gateway/src/apicast/http_proxy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,20 @@ local function current_path(uri)
end

local function forward_https_request(proxy_uri, uri)
-- This is needed to call ngx.req.get_body_data() below.
ngx.req.read_body()

local request = {
uri = uri,
method = ngx.req.get_method(),
headers = ngx.req.get_headers(0, true),
path = current_path(uri),
body = http:get_client_body_reader(),

-- We cannot use resty.http's .get_client_body_reader().
-- The result of that is nil, and it results in a time-out in some
-- cases. Possibly because of this:
-- https://github.com/ledgetech/lua-resty-http/issues/31
body = ngx.req.get_body_data(),
}

local httpc, err = http_proxy.new(request)
Expand Down

0 comments on commit 791301a

Please sign in to comment.