Hi Alex,
You are not the first person to say I'm working too hard, too fast and need to 
slow down. But why break the habit of a lifetime!!
Anyway, I'm already using that function, but the body is empty and content 
length zero.
This is what I have in kamailio.cfg:
  append_to_reply("Test: This is a custom header\r\n");  set_body("This is a 
custom body\r\n", "text/plain");  send_reply("200","OK");  exit;
And this is the response from a packet capture:
  SIP/2.0 200 OK  Via: SIP/2.0/TCP 
154.20.1.8:48689;branch=z9hG4bK-1711745743;rport=48689;received=2.221.73.230  
From: <sip:[email protected]>;tag=1764815333  To: 
<sip:r-ruri.without.username>;tag=0ea7681ffd64b0ffcde1bff3393fd505.3f21  
Call-ID: ba8cead2-2631-9daa-cda9-12f26524ac99  CSeq: 1593640028 INVITE  Test: 
This is a custom header  Server: kamailio (5.2.2 (x86_64/linux))  
Content-Length: 0
I can see the custom header and custom body being set in the debug logs, so I 
assume the body is being dropped somewhere within the SL module:
kamailio[23307]: 18(23356) exec: {1 1593640028 INVITE 
ba8cead2-2631-9daa-cda9-12f26524ac99} *** cfgtrace:request_route=[TEST] 
c=[/etc/kamailio/kamailio.cfg] l=1247 a=25 n=append_to_replykamailio[23307]: 
18(23356) exec: {1 1593640028 INVITE ba8cead2-2631-9daa-cda9-12f26524ac99} *** 
cfgtrace:request_route=[TEST] c=[/etc/kamailio/kamailio.cfg] l=1249 a=26 
n=set_bodykamailio[23307]: 18(23356) DEBUG: {1 1593640028 INVITE 
ba8cead2-2631-9daa-cda9-12f26524ac99} textops [textops.c:2004]: ki_set_body(): 
new body: [This is a custom bodykamailio[23307]: ]18(23356) exec: {1 1593640028 
INVITE ba8cead2-2631-9daa-cda9-12f26524ac99} *** cfgtrace:request_route=[TEST] 
c=[/etc/kamailio/kamailio.cfg] l=1255 a=26 n=send_replykamailio[23307]: 
18(23356) DEBUG: {1 1593640028 INVITE ba8cead2-2631-9daa-cda9-12f26524ac99} sl 
[sl.c:288]: send_reply(): reply in stateless mode (sl)kamailio[23307]: 
18(23356) DEBUG: {1 1593640028 INVITE ba8cead2-2631-9daa-cda9-12f26524ac99} 
<core> [core/tcp_main.c:2225]: tcpconn_send_put(): send from reader (23356 
(18)), reusing fdkamailio[23307]: 18(23356) DEBUG: {1 1593640028 INVITE 
ba8cead2-2631-9daa-cda9-12f26524ac99} <core> [core/tcp_main.c:2460]: 
tcpconn_do_send(): sending...kamailio[23307]: 18(23356) DEBUG: {1 1593640028 
INVITE ba8cead2-2631-9daa-cda9-12f26524ac99} <core> [core/tcp_main.c:2494]: 
tcpconn_do_send(): after real write: c= 0x7f8d24e74988 n=429 
fd=12kamailio[23307]: 18(23356) DEBUG: {1 1593640028 INVITE 
ba8cead2-2631-9daa-cda9-12f26524ac99} <core> [core/tcp_main.c:2495]: 
tcpconn_do_send(): buf=

Thanks.


    On Thursday, 18 April 2019, 19:51:52 BST, Alex Balashov 
<[email protected]> wrote:  
 
 David,

As usual, you are working too hard, too fast, and need to slow down,
breathe, relax, practice some "mindfulness techniques", and take a
meditative stroll through the documentation. :-)

https://kamailio.org/docs/modules/5.2.x/modules/textops.html#textops.f.set_reply_body

-- Alex

On Thu, Apr 18, 2019 at 06:47:52PM +0000, David Dean wrote:

>  I've been reviewing the code for the sl module to try and see if it can be 
>modified to send the current body with send_reply().
> However I'm not a C programmer so I'm fumbling around in the dark!
> I came across this section in sl_funcs.c
>  /* if that is a redirection message, dump current message set to it */ if 
>(code>=300 && code<400) { dset.s=print_dset(msg, &dset.len, sl_rich_redirect); 
>if (dset.s) { add_lump_rpl(msg, dset.s, dset.len, LUMP_RPL_HDR); } }
> If this was modified to include LUMP_RPL_BODY then could that be made to work?
> Or is there a better way of tweaking this SL module to include the body in 
> the response when using send_reply()?
> Thanks, Dave
>    On Tuesday, 16 April 2019, 23:28:06 BST, David Dean 
><[email protected]> wrote:  
>  
>  Hello Kamailio gurus,
> I'm successfully using send_reply() with append_to_reply() to add some custom 
> headers.
> Now I need to add some text into the reply body.
> How can I add a body to send_reply() ?
> Thx, Dave
>  

> _______________________________________________
> Kamailio (SER) - Users Mailing List
> [email protected]
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


-- 
Alex Balashov | Principal | Evariste Systems LLC

Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free) 
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/

_______________________________________________
Kamailio (SER) - Users Mailing List
[email protected]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
  
_______________________________________________
Kamailio (SER) - Users Mailing List
[email protected]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

Reply via email to