|
1 | 1 | local format = string.format |
2 | 2 | local tostring = tostring |
| 3 | +local ngx = ngx |
3 | 4 | local ngx_get_method = ngx.req.get_method |
4 | 5 | local ngx_http_version = ngx.req.http_version |
| 6 | +local ngx_req_get_headers = ngx.req.get_headers |
5 | 7 |
|
6 | 8 | local resty_url = require "resty.url" |
7 | 9 | local url_helper = require('resty.url_helper') |
@@ -49,9 +51,9 @@ local function forward_https_request(proxy_uri, uri, proxy_opts) |
49 | 51 | local sock |
50 | 52 | local opts = proxy_opts or {} |
51 | 53 | local req_method = ngx_get_method() |
52 | | - local encoding = ngx.req.get_headers()["Transfer-Encoding"] |
| 54 | + local encoding = ngx_req_get_headers()["Transfer-Encoding"] |
53 | 55 | local is_chunked = encoding and encoding:lower() == "chunked" |
54 | | - local content_type = ngx.req.get_headers()["Content-Type"] |
| 56 | + local content_type = ngx_req_get_headers()["Content-Type"] |
55 | 57 | local content_type_is_urlencoded = content_type and content_type:lower() == "application/x-www-form-urlencoded" |
56 | 58 | local raw = false |
57 | 59 |
|
@@ -138,9 +140,9 @@ local function forward_https_request(proxy_uri, uri, proxy_opts) |
138 | 140 |
|
139 | 141 | local request = { |
140 | 142 | uri = uri, |
141 | | - method = ngx.req.get_method(), |
142 | | - headers = ngx.req.get_headers(0, true), |
143 | | - path = format('%s%s%s', ngx.var.uri, ngx.var.is_args, ngx.var.query_string or ''), |
| 143 | + method = req_method, |
| 144 | + headers = ngx_req_get_headers(0, true), |
| 145 | + path = (ngx.var.uri or '') .. (ngx.var.is_args or '') .. (ngx.var.query_string or ''), |
144 | 146 | body = body, |
145 | 147 | proxy_uri = proxy_uri, |
146 | 148 | proxy_options = opts |
@@ -194,7 +196,7 @@ function _M.request(upstream, proxy_uri) |
194 | 196 | local proxy_auth |
195 | 197 |
|
196 | 198 | if proxy_uri.user or proxy_uri.password then |
197 | | - proxy_auth = "Basic " .. ngx.encode_base64(concat({ proxy_uri.user or '', proxy_uri.password or '' }, ':')) |
| 199 | + proxy_auth = "Basic " .. ngx.encode_base64((proxy_uri.user or '') .. ":" .. (proxy_uri.password or '')) |
198 | 200 | end |
199 | 201 |
|
200 | 202 | if uri.scheme == 'http' then -- rewrite the request to use http_proxy |
|
0 commit comments