MINOR: httpclient/lua: httpclient:get() API in lua
authorWilliam Lallemand <wlallemand@haproxy.org>
Tue, 21 Sep 2021 14:25:15 +0000 (16:25 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Fri, 24 Sep 2021 12:29:36 +0000 (14:29 +0200)
commit3956c4ead20abf750d0685205e0fece8bb343350
tree75e8c0bb3c5b1b024b45f763d7438a73625664d0
parent1123dde6dd31a09ffcf173513b0282d03cf62793
MINOR: httpclient/lua: httpclient:get() API in lua

This commit provides an hlua_httpclient object which is a bridge between
the httpclient and the lua API.

The HTTPClient is callable in lua this way:

    local httpclient = core.httpclient()
    local response = httpclient:get("http://127.0.0.1:9000/?s=9999")
    core.Debug("Status: ".. res.status .. ", Reason : " .. res.reason .. ", Len:" .. string.len(res.body) .. "\n")

The resulting response object will provide a "status" field which
contains the status code, a "reason" string which contains the reason
string, and a "body" field which contains the response body.

The implementation uses the httpclient callback to wake up the lua task
which yield each time it pushes some data. The httpclient works in the
same thread as the lua task.
include/haproxy/hlua-t.h
src/hlua.c