function _M.get_proxy_uri()

in lib/resty/http.lua [1043:1091]


function _M.get_proxy_uri(self, scheme, host)
    if not self.proxy_opts then
        return nil
    end

    
    
    if self.proxy_opts.no_proxy then
        if self.proxy_opts.no_proxy == "*" then
            
            return nil
        end

        local no_proxy_set = {}
        
        
        for host_suffix in ngx_re_gmatch(self.proxy_opts.no_proxy, "\\.?([^,]+)") do
            no_proxy_set[host_suffix[1]] = true
        end

        
        
        
        
        
        
        
        
        repeat
            if no_proxy_set[host] then
                return nil
            end

            
            
            host = ngx_re_sub(host, "^[^.]+\\.", "")
        until not ngx_re_find(host, "\\.")
    end

    if scheme == "http" and self.proxy_opts.http_proxy then
        return self.proxy_opts.http_proxy
    end

    if scheme == "https" and self.proxy_opts.https_proxy then
        return self.proxy_opts.https_proxy
    end

    return nil
end