diff options
| author | William Lallemand <wlallemand@haproxy.org> | 2021-10-26 15:01:53 +0200 |
|---|---|---|
| committer | William Lallemand <wlallemand@haproxy.org> | 2021-10-27 10:19:58 +0200 |
| commit | 6137a9ee204cc01ebb9e17f4e22cfaefb9d61ac8 (patch) | |
| tree | d1cd59d37494f094ca64ddd7bf455afb0b915f52 /src/hlua.c | |
| parent | dc2cc9008bf2518e4a4130c224983bc4c710d386 (diff) | |
| download | haproxy-httpclient-lua-2021-10-27.tar.gz | |
MINOR: httpclient/lua: return an error when it can't generate the requesthttpclient-lua-2021-10-27
Add a check during the httpclient request generation which yield an lua
error when the generation didn't work. The most common case is the lack
of space in the buffer, it can because of too much headers or a too big
body.
Diffstat (limited to 'src/hlua.c')
| -rw-r--r-- | src/hlua.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/hlua.c b/src/hlua.c index d3c76845d..27c62165c 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -7209,8 +7209,7 @@ __LJMP static int hlua_httpclient_send(lua_State *L, enum http_meth_t meth) hlua_hc->hc->ops.res_end = hlua_httpclient_res_cb; - httpclient_req_gen(hlua_hc->hc, hlua_hc->hc->req.url, meth, hdrs, ist(body_str)); - httpclient_start(hlua_hc->hc); + ret = httpclient_req_gen(hlua_hc->hc, hlua_hc->hc->req.url, meth, hdrs, ist(body_str)); /* free the temporary headers array */ hdrs_i = hdrs; @@ -7222,6 +7221,13 @@ __LJMP static int hlua_httpclient_send(lua_State *L, enum http_meth_t meth) ha_free(&hdrs); + if (ret != ERR_NONE) { + WILL_LJMP(luaL_error(L, "Can't generate the HTTP request")); + return 0; + } + + + httpclient_start(hlua_hc->hc); /* we return a "res" object */ lua_newtable(L); |
