[Kamailio-Users] How to add Retry-After header in 503 response

Daniel-Constantin Mierla miconda at gmail.com
Thu Nov 27 18:52:12 CET 2008


On 11/27/08 16:49, Alex Hermann wrote:
> On Thursday 27 November 2008, Henning Westerholt wrote:
>   
>> On Thursday 27 November 2008, Alex Hermann wrote:
>>     
>>> is there a way to add a Retry-After header to a 503 response i'm sending
>>> out using t_reply?
>>>
>>> Use case: t_relay creates an internal 408 on timeout. From failure-route,
>>> i want to pass it upstream as 503 with retry-after header. Changing the
>>> reply to 503 using t_reply works, but how to add the header?
>>>
>>> The reply obviously doens't pass through any reply_route.
>>>       
>> Hi Alex,
>>
>> have you tried using append_to_reply("Retry-After: 120\n"); before the
>> sl_send_reply or t_reply?
>>     
>
> Well, as it is marked to not be usable from failure route I hadn't considered 
> it.
>
> The following fragment seems to work, so I'll assume it is safe to call 
> append_to_reply from failure_route itself.
yes, it is safe. It is important to understand that this operation 
affects replies generated from request by kamailio, not the ones that 
pass through -- one can use append_hf() in onreply_route to add headers 
to these kind of replies.

I will apply the patch, thanks.

Cheers,
Daniel

>  Attached (tested) patch does this, 
> please apply.
>
>
> <failure route>
> if (t_local_replied("all")) {
> 	route(78);
> 	t_reply("503", "Service Unavailable");
> }
>
>
> route[78] {
> 	append_to_reply("Retry-After: 53\r\n");
> 	return;
> }
>
>
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.kamailio.org
> http://lists.kamailio.org/cgi-bin/mailman/listinfo/users

-- 
Daniel-Constantin Mierla
http://www.asipto.com





More information about the sr-users mailing list