Hi. I'm building small HTTP API using kemi lua on kamailio 5.1 version:
kamailio -v version: kamailio 5.1.2 (x86_64/linux) flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB poll method support: poll, epoll_lt, epoll_et, sigio_rt, select. id: unknown compiled on 18:16:53 Apr 7 2018 with gcc 4.8.5
On the system Linux CentOS-74-64-minimal 3.10.0-693.17.1.el7.x86_64 #1 SMP Thu Jan 25 20:13:58 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
When i sending xhttp_reply I getting wrong code that kamailio sends to the client instead of code I use Im used as this exmaple as template int xhttp_reply(int code, str "reason", str "ctype", str "body") as classic (with code in string)
`KSR.xhttp.xhttp_reply("200", "OK", application/json, "")`
So in both cases I getting next trouble:
When i trying to set params to the xhttp_reply i getting this in the log (on debug layer)
DEBUG: app_lua [app_lua_sr.c:1500]: sr_kemi_lua_exec_func_ex(): param[0] for: xhttp_reply is int: 200 DEBUG: app_lua [app_lua_sr.c:1496]: sr_kemi_lua_exec_func_ex(): param[1] for: xhttp_reply is str: OK DEBUG: app_lua [app_lua_sr.c:1496]: sr_kemi_lua_exec_func_ex(): param[2] for: xhttp_reply is str: application/json
but next string I shows DEBUG: xhttp [xhttp_mod.c:443]: xhttp_send_reply(): sending out response: 161110576 OK
This first 3 digits at the reslonse I see **161** 110576
Digits are random, as positive as negative (with "-" at the start)
Did you get also a debug message for the 4th parameter, like next?
``` DEBUG: app_lua [app_lua_sr.c:1496]: sr_kemi_lua_exec_func_ex(): param[3] for: xhttp_reply is str: ... ```
Sure THere were data inside so I didnt post it Her output including it And also it the response 3 last digits (512 in this particular case)
DEBUG: app_lua [app_lua_sr.c:1500]: sr_kemi_lua_exec_func_ex(): param[0] for: xhttp_reply is int: 200 DEBUG: app_lua [app_lua_sr.c:1496]: sr_kemi_lua_exec_func_ex(): param[1] for: xhttp_reply is str: OK DEBUG: app_lua [app_lua_sr.c:1496]: sr_kemi_lua_exec_func_ex(): param[2] for: xhttp_reply is str: application/json app_lua [app_lua_sr.c:1496]: sr_kemi_lua_exec_func_ex(): param[3] for: xhttp_reply is str: [{"id":"fg8szja2f8rwobez","members":["1","3","43","56","71","81"]},{"id":"d588u674jpdumyhi","members":["43","64","65","98","99"]},{"id":"6tlsq7x1gqwrc3yk","members":["43","98"]}]
DEBUG: xhttp [xhttp_mod.c:431]: xhttp_send_reply(): response with content-type: application/json DEBUG: xhttp [xhttp_mod.c:441]: xhttp_send_reply(): response with body: [{"id":"fg8szja2f8rwobez","members":["1","3","43","56","71","81"]},{"id":"d588u674jpdumyhi","members":["43","64","65","98","99"]},{"id":"6tlsq7x1gqwrc3yk","members":["43","98"]}]
DEBUG: xhttp [xhttp_mod.c:443]: xhttp_send_reply(): sending out response: 1810880**512** OK
I wanted just to be sure it doesn't have some other issues as well.
Otherwise, for the reported case, I just pushed two commit in master branch (see above the one for app_lua, another one inc ore). Can you try with master? If all ok, I will backport.
Sure I will write here in a couple of hours
Yep fixed For now responses are valid
Closed #1544.