]> git.kaiwu.me - haproxy.git/commit
MEDIUM: httpclient/lua: allow multiple requests from a single core.httpclient() instance
authorWilliam Lallemand <wlallemand@irq6.net>
Sat, 13 Jun 2026 23:04:05 +0000 (01:04 +0200)
committerWilliam Lallemand <wlallemand@irq6.net>
Sat, 13 Jun 2026 23:49:54 +0000 (01:49 +0200)
commit0748799ad18db4eeb72b33b30c5e0c420a8216ea
tree82910e29faff7f6d56ff00d223ede04856ee3197
parent339d25636dae350b2622c39b0b34a4f41d1a7842
MEDIUM: httpclient/lua: allow multiple requests from a single core.httpclient() instance

Refactor the Lua HTTP client to defer initialization. core.httpclient()
no longer initializes the internal HTTP client immediately. Instead,
initialization now occurs within hlua_httpclient_send() when a request
method (e.g., get, put, head) is invoked.

The HTTPClient class now serves as a factory for accessing methods, while
a new class, HTTPClientRequest, has been introduced to represent individual
requests and manage the HTTP client lifecycle.

This change allows multiple requests to be executed using a single
HTTP client instance:

  local hc = core.httpclient()
  local res1 = hc:get({url = "...", headers = ...})
  local res2 = hc:post({url = "...", headers = ...})
  local res3 = hc:put({url = "...", headers = ...})

This refactor maintains backward compatibility, as existing scripts that
instantiate a new core.httpclient() for every request will continue to
work as expected.
doc/lua-api/index.rst
include/haproxy/hlua-t.h
reg-tests/lua/lua_httpclient.lua
src/http_client.c