:param string request.url: Is a mandatory parameter for the request that contains the URL.
:param string request.body: Is an optional parameter for the request that contains the body to send.
:param table request.headers: Is an optional parameter for the request that contains the headers to send.
+ :param table request.dst: Is an optional parameter for the destination in haproxy address format.
:returns: Lua table containing the response
.. code-block:: lua
local httpclient = core.httpclient()
- local response = httpclient:post{url="http://127.0.0.1", body=body}
+ local response = httpclient:post{url="http://127.0.0.1", body=body, dst="unix@/var/run/http.sock"}
..
["content-type"] = { "text/html" },
["cache-control"] = { "no-cache", "no-store" },
},
- body = "<html><body><h1>invalid request<h1></body></html>"
+ body = "<html><body><h1>invalid request<h1></body></html>",
}
..
core.Info("Third httpclient request")
local httpclient3 = core.httpclient()
- local response3 = httpclient3:get{url="http://127.0.0.1:" .. vtc_port3, headers={ [ "Host" ] = { "foobar.haproxy.local" } }}
+ local response3 = httpclient3:get{url="http://127.0.0.1", dst = vtc_port3, headers={ [ "Host" ] = { "foobar.haproxy.local" } }}
end
mode http
http-request use-service lua.fakeserv
+ listen li1
+ mode http
+ bind unix@${testdir}/srv3
+ server srv3 ${s3_addr}:${s3_port}
+
} -start
client c0 -connect ${h1_fe1_sock} {
- txreq -url "/" -hdr "vtcport: ${s1_port}" -hdr "vtcport2: ${s2_port}" -hdr "vtcport3: ${s3_port}"
+ txreq -url "/" -hdr "vtcport: ${s1_port}" -hdr "vtcport2: ${s2_port}" -hdr "vtcport3: unix@${testdir}/srv3"
rxresp
expect resp.status == 200
} -run
if (lua_gettop(L) != 2 || lua_type(L, -1) != LUA_TTABLE)
WILL_LJMP(luaL_error(L, "'get' needs a table as argument"));
+ hlua_hc = hlua_checkhttpclient(L, 1);
+
+ ret = lua_getfield(L, -1, "dst");
+ if (ret == LUA_TSTRING) {
+ if (httpclient_set_dst(hlua_hc->hc, lua_tostring(L, -1)) < 0)
+ WILL_LJMP(luaL_error(L, "Can't use the 'dst' argument"));
+ }
+ lua_pop(L, 1);
+
ret = lua_getfield(L, -1, "url");
if (ret == LUA_TSTRING) {
url_str = lua_tostring(L, -1);
return 0;
}
- hlua_hc = hlua_checkhttpclient(L, 1);
hlua_hc->hc->req.url = istdup(ist(url_str));
hlua_hc->hc->req.meth = meth;