Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add_body() doesn't insert content-type #698

Closed
achalkov opened this issue Nov 13, 2015 · 7 comments
Closed

add_body() doesn't insert content-type #698

achalkov opened this issue Nov 13, 2015 · 7 comments
Assignees

Comments

@achalkov
Copy link

version: opensips 2.1.1 (x86_64/linux)
flags: STATS: On, DISABLE_NAGLE, USE_MCAST, SHM_MMAP, PKG_MALLOC, F_MALLOC, FAST_LOCK-ADAPTIVE_WAIT
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
main.c compiled on 00:00:43 Aug 29 2015 with gcc 4.4.7

When i trying to insert new body to some message in local_route by using add_body("$var(newbody)", "application/dialog-info+xml"), it inserts body itself, but doesn't insert content-type header

@ionutrazvanionita
Copy link
Contributor

I did as you specified, but it works ok for me. The message looks like this

U 2015/11/13 18:28:35.341090 192.168.2.6:5060 -> 192.168.2.6:5080
INVITE sip:192.168.2.6:5080 SIP/2.0.
Via: SIP/2.0/UDP 192.168.2.6:5060;branch=z9hG4bK3e49.df36162.0.
To: sipp <sip:192.168.2.6>.
From: opensips <sip:192.168.2.6:5060>;tag=f27851d028408c385ef0691f4f0a49c1-b62b.
CSeq: 10 INVITE.
Call-ID: 7a5bf9fd-7912@192.168.2.6.
Max-Forwards: 70.
Content-Length: 12.
User-Agent: OpenSIPS (2.1.1 (i386/linux)).
Content-Type: application/dialog-info+xml.
.
Hello World!

and i generate a t_new_request() on each INVITE received. Are you modifying the message with any other function before or after you call add_body()?

@achalkov
Copy link
Author

yes, before add_body() i do some work with variables and also call strip_body().
I didn't check this function with INVITE, but my use-case is about transform xml body of PUBLISH request, generated locally by opensips itself to publish some information for presence.

@ionutrazvanionita
Copy link
Contributor

@achalkov I guess you get the bug because the new body has the same Content-Type with the one you strip. Because of this, there is an incompatibility between strip_body() and add_body() functions, because of the lumps(opensips message editing mechanism). Anyhow, isn't the add_body() function enough for what you need? Don't know whether you read the docs, but they state that " If a body already exists, it will be replaced with the new one."[0] So you don't need to call the strip_body() function.

[0]http://www.opensips.org/html/docs/modules/2.2.x/sipmsgops.html#id294297

@achalkov
Copy link
Author

but Bogdan said that to push new body, both strip_body() and add_body() must be called (proof: http://opensips.org/pipermail/users/2014-October/030200.html)

@ionutrazvanionita
Copy link
Contributor

Bogdan might have missed this, but after you strip the body, and you add another one, the content type will not be set in your case

@ionutrazvanionita
Copy link
Contributor

I'm going to close this ticket. If it doesn't work without strip_body() you can reopen it.

@achalkov
Copy link
Author

ok, thanks. i'll try ur solution later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants