ledgetech / ledgetech/lua-resty-http
What sequence of API calls should be made when calling through HTTP Proxy?
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 2.1k
- Forks
- 630
- PR merge metrics
- No merged PRs in 30d
Description
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
connectwhen 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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the mentioned entry points: set_proxy_options, request_uri, connect, ssl_handshake, and request. Check the library documentation or source to verify both proxy and direct-call sequences, including HTTPS behavior; done means the supported sequence and handshake requirements are clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, nginx
- Domain
- networking
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100