I am using openresty http library (v0.16.1) inside a custom kong plugin. I need to make an api call through a http proxy if it is configured. So my current code looks as below -
The sequence of api calls made when going through proxy are
- set_proxy_options
- request_uri
While the sequence of api calls made when directly calling the remote host are
- connect
- ssl_handshake
- request
Below are my questions
- Are the api call sequences accurate in both the scenarios?
- Why don't we need to call
connect when going through the proxy?
- Should ssl handshaking be done when going through the proxy? If so, how?
Thanks.
if conf.proxy_uri then
kong.log.notice("Setting the proxy options")
local proxy_opts = {
http_proxy = conf.proxy_uri,
https_proxy = conf.proxy_uri
}
httpc:set_proxy_options(proxy_opts)
kong.log.notice("Making http request through proxy")
res, err = httpc:request_uri(conf.api_path_, auth_request)
_M.process_response(res, res.body, err)
else
kong.log.notice("Connecting directly to the remote host")
httpc:connect(host, port)
if scheme == "https" then
ok, err = httpc:ssl_handshake()
if not ok then
kong.log.err(err)
return kong.response.exit(500, { message = "An unexpected error occurred during ssl handshake."})
end
end
res, err = httpc:request(auth_request)
_M.process_response(res, res:read_body(), err)
end
I am using openresty http library (v0.16.1) inside a custom kong plugin. I need to make an api call through a http proxy if it is configured. So my current code looks as below -
The sequence of api calls made when going through proxy are
While the sequence of api calls made when directly calling the remote host are
Below are my questions
connectwhen going through the proxy?Thanks.