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().
In some POST requests with HTTPS, the result of that call is nil, and it
results in a time-out.
  • Loading branch information
davidor committed Jan 15, 2019
1 parent a4ee88d commit e1dc0b6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gateway/src/apicast/http_proxy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,19 @@ 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().
-- In POST requests with HTTPS, the result of that call is nil, and it
-- results in a time-out.
body = ngx.req.get_body_data(),
}

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

0 comments on commit e1dc0b6

Please sign in to comment.