Tried append_to_reply from textutils in event_route[xhttp:request] - which is not a documented usage. It did not generate an error about a bad route, but did not seem to append the header to the response.
This may be a feature request, but wouldn't it be cool if it worked?
I think it should work, the content-type header is added in the same fashion based on the appropriate parameter inside the xhttp_reply(). If you send a reply with content-type and body, does the header appears or only the body?
This was without body. I'll try with a body.
You are right, it works when there is a body!
Strange, because what I meant is that append_to_reply() is doing same operation as done by xhttp_reply() when it has to add content-type header. Adding body is another type of operation. Can you try with content-type parameter and an empty string for body parameter?
Any time to test further on this item?
Yes, that worked - Happily added the "Reason" header here. So this is a work-around that we may have to document until we have a solution.
```
GET http://localhost:5060/api/1.0/ping HTTP/1.1 Host: localhost:5060 User-Agent: curl/7.52.1 Accept: */*
< HTTP/1.1 200 Ping pong < Sia: SIP/2.0/TCP 127.0.0.1:57458 < Reason: Answering ping API request /api/1.0/ping < Content-Type: text/html < Content-Length: 0 < Date: Tue, 12 Jun 2018 12:38:41 GMT < Age: 0
```
I just tried with master and 5.1 branches and all is ok.
``` event_route[xhttp:request] { append_to_reply("X-Orig: $si:$sp\r\n");
xhttp_reply("200", "OK", "", ""); } ```
Then:
``` # curl -v http://192.168.188.25:5060 * Rebuilt URL to: http://192.168.188.25:5060/ * Trying 192.168.188.25... * TCP_NODELAY set * Connected to 192.168.188.25 (192.168.188.25) port 5060 (#0)
GET / HTTP/1.1 Host: 192.168.188.25:5060 User-Agent: curl/7.60.0 Accept: */*
< HTTP/1.1 200 OK < Sia: SIP/2.0/TCP 192.168.188.25:58888 < X-Orig: 192.168.188.25:58888 < Server: kamailio (5.1.4 (x86_64/darwin)) < Content-Length: 0 < * Connection #0 to host 192.168.188.25 left intact ```
So either is an older kamailio version or something specific for your settings.
Any updates on this one? Not being able to reproduce with latest versions. If not, then I will close this in a few days.
Can't reproduce the bug in latest code. Thanks!
Closed #1548.