ledgetech / ledgetech/lua-resty-http

What sequence of API calls should be made when calling through HTTP Proxy?

Open
#288 5 comments 0 reactions 0 assignees View on GitHub

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

  1. set_proxy_options
  2. request_uri

While the sequence of api calls made when directly calling the remote host are

  1. connect
  2. ssl_handshake
  3. request

Below are my questions

  1. Are the api call sequences accurate in both the scenarios?
  2. Why don't we need to call connect when going through the proxy?
  3. 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.