[OpenSIPS-Users] Getting header from 302

Johan De Clercq Johan at democon.be
Wed Jun 2 14:18:38 EST 2021


that's because 302 is not an error.
So I guess that drop() is the only way.

Op wo 2 jun. 2021 om 15:42 schreef David Villasmil <
david.villasmil.work at gmail.com>:

> Thanks Ben,
>
> That’s a good point. But only way I’ve found to jump over from oneply to
> failure_route is by doing a drop(). If there’s another way, I’d love to
> know about it!
>
> David
>
> On Wed, 2 Jun 2021 at 08:29, Ben Newlin <Ben.Newlin at genesys.com> wrote:
>
>> You still don’t need to call drop() as long as you are handling the
>> request in failure_route. The 302 will not be sent back upstream as long as
>> failure_route either creates a new branch request or sends back a different
>> reply code. Only if failure_route exits without doing either of these
>> things would the downstream 302 be sent back upstream as-is.
>>
>>
>>
>> In fact, as far as I know drop() has no functionality for responses >=
>> 200.
>>
>>
>>
>> Ben Newlin
>>
>>
>>
>> *From: *Users <users-bounces at lists.opensips.org> on behalf of Jeff Pyle <
>> jeff at ugnd.org>
>> *Date: *Tuesday, June 1, 2021 at 2:48 PM
>> *To: *OpenSIPS users mailling list <users at lists.opensips.org>
>> *Subject: *Re: [OpenSIPS-Users] Getting header from 302
>>
>> Oh!  Understood.
>>
>>
>>
>>
>>
>> - Jeff
>>
>>
>>
>>
>>
>> On Tue, Jun 1, 2021 at 2:42 PM David Villasmil <
>> david.villasmil.work at gmail.com> wrote:
>>
>> The thing is I _want_ to drop the 302, I don't want to do anything else
>> with it.
>>
>>
>> Regards,
>>
>>
>>
>> David Villasmil
>>
>> email: david.villasmil.work at gmail.com
>>
>> phone: +34669448337
>>
>>
>>
>>
>>
>> On Tue, Jun 1, 2021 at 6:46 PM Jeff Pyle <jeff at ugnd.org> wrote:
>>
>> In my experience you don't need drop() in the reply route.  Just store
>> the AVP and move on.  Something like this:
>>
>>
>>
>> onreply_route[collect_identity] {
>>
>>     if (is_present_hf("Identity")) {
>>
>>         $avp(identity) := $hdr(Identity);
>>
>>         setflag("GOT_IDENTITY");
>>
>>     }
>>
>> }
>>
>>
>>
>> If you've armed both the reply and failure routes with t_on_reply() and
>> t_on_failure(), the $avp(identity) variable set here will be available in
>> the failure_route.  The GOT_IDENTITY flag, too.
>>
>>
>>
>>
>>
>> - Jeff
>>
>>
>>
>>
>>
>>
>>
>> - Jeff
>>
>>
>>
>>
>>
>> On Tue, Jun 1, 2021 at 11:20 AM David Villasmil <
>> david.villasmil.work at gmail.com> wrote:
>>
>> Yes, I see it is documented.
>>
>>
>>
>> So the reply header is only availanble on the "onreply" route, not on the
>> "failure" route. That was my problem. I do indeed use an avp to store the
>> header.
>>
>> I ended up getting the header on the "onreply" and storing it in an avp,
>> set a flag and then drop(). I noticed the "failure" route is then executed.
>>
>> From there I can send the processing to the invite route and by  checking
>> the flag, adding the header from the avp.
>>
>>
>>
>> Thanks for your help!
>>
>>
>> Regards,
>>
>>
>>
>> David Villasmil
>>
>> email: david.villasmil.work at gmail.com
>>
>> phone: +34669448337
>>
>>
>>
>>
>>
>> On Tue, Jun 1, 2021 at 3:52 PM Ben Newlin <Ben.Newlin at genesys.com> wrote:
>>
>> It’s documented that it works this way. The message being processed in
>> failure_route is the original request; in reply_route it’s the reply. [1]
>>
>>
>>
>> You can use variable context to access the reply from failure_route [2].
>> Another option would be to extract the header value into and AVP in
>> reply_route and then reference the AVP from failure_route.
>>
>>
>>
>>
>>
>> [1] - https://www.opensips.org/Documentation/Script-Routes-3-2
>>
>> [2] - https://www.opensips.org/Documentation/Script-CoreVar-3-2
>>
>>
>>
>> Ben Newlin
>>
>>
>>
>> *From: *Users <users-bounces at lists.opensips.org> on behalf of David
>> Villasmil <david.villasmil.work at gmail.com>
>> *Date: *Tuesday, June 1, 2021 at 10:43 AM
>> *To: *OpenSIPS users mailling list <users at lists.opensips.org>
>> *Subject: *Re: [OpenSIPS-Users] Getting header from 302
>>
>> Yeah, my thing is when i use the failure route i can in theory grab the
>> response header and ignore the 302 and send to the invite route again to
>> actually send the call out via do_routing.
>>
>> What I'm trying to do is:
>>
>> - On receiving an invite: forward to an endpoint.
>>
>> - This endpoint will simply reply with 302 including a header.
>>
>> - I want to grab that header and continue routing normally (do_routing)
>>
>>
>>
>> I could do that with the failure route, but not so sure about the onreply
>> route.
>>
>>
>> Regards,
>>
>>
>>
>> David Villasmil
>>
>> email: david.villasmil.work at gmail.com
>>
>> phone: +34669448337
>>
>>
>>
>>
>>
>> On Tue, Jun 1, 2021 at 2:34 PM Jeff Pyle <jeff at ugnd.org> wrote:
>>
>> I don't think you're doing anything wrong.  I think I found the same
>> thing, that headers on the reply were available only in a reply route and
>> not in a failure route.  If you know where to look for them to populate the
>> AVP, I suppose it doesn't matter much.
>>
>>
>>
>> I haven't looked at the code but I suspect all the routes other than an
>> onreply_route give you access to the requests headers, and onreply_route
>> gives you access to the reply headers.  Makes sense I guess.
>>
>>
>>
>>
>>
>> - Jeff
>>
>>
>>
>>
>>
>> On Tue, Jun 1, 2021 at 9:31 AM David Villasmil <
>> david.villasmil.work at gmail.com> wrote:
>>
>> Thanks Jeff,
>>
>>
>>
>> MMM, that's strange, I was using it on failure route and the route was
>> being executed, but the data wasn't there. I put it on the onreply route
>> and that one is now executed with the data correctly there...
>>
>>
>>
>> I probably did something wrong.
>>
>>
>>
>> Thanks again Jeff!
>>
>>
>> Regards,
>>
>>
>>
>> David Villasmil
>>
>> email: david.villasmil.work at gmail.com
>>
>> phone: +34669448337
>>
>>
>>
>>
>>
>> On Tue, Jun 1, 2021 at 12:37 PM Jeff Pyle <jeff at ugnd.org> wrote:
>>
>> In which route are you trying to use if (is_present_hf("Identity"))?
>> Since the 302 is both a reply and a "failure", I suggest seeing if it
>> appears in either the armed onreply_route or failure_route.
>>
>>
>>
>> I think From is available because it was present in the original request
>> route.
>>
>>
>>
>>
>>
>> - Jeff
>>
>>
>>
>> On Tue, Jun 1, 2021 at 5:39 AM David Villasmil <
>> david.villasmil.work at gmail.com> wrote:
>>
>> Anyone has any idea about this? Appreciate your help.
>>
>>
>>
>> On Mon, 31 May 2021 at 21:11, David Villasmil <
>> david.villasmil.work at gmail.com> wrote:
>>
>> So weird,
>>
>> I can get the From header, but not "Identity"...
>>
>>
>> Regards,
>>
>>
>>
>> David Villasmil
>>
>> email: david.villasmil.work at gmail.com
>>
>> phone: +34669448337
>>
>>
>>
>>
>>
>> On Mon, May 31, 2021 at 8:22 PM David Villasmil <
>> david.villasmil.work at gmail.com> wrote:
>>
>> This is really weird,
>>
>>
>>
>> if (is_present_hf("Identity"))
>>
>>
>>
>> says it is not present, but it is!
>>
>>
>> Regards,
>>
>>
>>
>> David Villasmil
>>
>> email: david.villasmil.work at gmail.com
>>
>> phone: +34669448337
>>
>>
>>
>>
>>
>> On Mon, May 31, 2021 at 7:47 PM David Villasmil <
>> david.villasmil.work at gmail.com> wrote:
>>
>> Hello Guys,
>>
>>
>>
>> I'm getting a header on a 302 which i'm trying to get, but for some
>> reason I can't.
>>
>>
>>
>> This is an example 302:
>>
>>
>>
>> 2021/05/31 18:42:36.499157 10.231.32.237:5060 -> 10.231.57.11:6075
>> SIP/2.0 302 Redirect
>> Via: SIP/2.0/UDP 1.2.3.4
>> :6075;branch=z9hG4bKd8e8.50036ee6.0;received=10.231.57.11
>> Via: SIP/2.0/UDP
>> 10.231.33.135;branch=z9hG4bKd8e8.fe2738f41d26b2b68328691c326a077a.0
>> v:SIP/2.0/UDP 10.231.49.211:6060
>> ;received=10.231.49.211;rport=6060;branch=z9hG4bK68SgceeareaUa
>> f:"+18883333333"<sip:+18883333333 at 10.231.49.211>;tag=ZBQ713X9pgD5S
>> t:<sip:19992222222 at domain.com
>> >;tag=9dd61ff61e802d8e2bef5f14621ef3c2.50cf6b6c
>> i:cf649a38-3ce2-123a-eaad-122eaa5d9655
>> CSeq:36689486 INVITE
>> Identity:
>> eyJhbGciOiJFUzI1NiIsInBwdCI6InNoYWtlbiIsInR5cCI6InBhc3Nwb3J0IiwieDV1IjoiaHR0cHM6Ly9vcHMtc3RhdGljLnMzLmFtYXpvbmF3cy5jb20vc3Rpci1zaGFrZW4vZWMyNTYtcHVibGljLnBlbSJ9.eyJhdHRlc3QiO
>>
>> BIiwiZGVzdCI6eyJ0biI6WyIxNzg2NDEwNzgzNyJdfSwiaWF0IjoxNjIyNDg2NTU2LCJvcmlnIjp7InRuIjoiKzEzMTU5ODUyNTk0In0sIm9yaWdpZCI6IjhlZGE4M2Q1LWY1MjEtNDQzZC1iNDI0LWIzNDQ3MDc4ZjYxZCJ9.cjIz9VwlS9_6qA
>>
>> 6mmDgottk41BLpQcA40HdvV_6jAPqQ1EIL3_jLWl25oHeVEWOzTMhcERp4Jn-JZ4vP_n3w;info=<
>> https://somedomain.com/stir-shaken/ec256-public.pem>;alg=ES256;ppt=shaken
>> Server: kamailio (5.5.0 (x86_64/linux))
>> Content-Length: 0
>>
>>
>>
>> I'm trying to get the "Identity" header with:
>>
>>
>>
>> $avp(identity_header) = $(hdr(Identity));
>>
>>
>>
>> But It's coming up <null>
>>
>>
>>
>> Any ideas of what I'm doing wrong?
>>
>>
>> Regards,
>>
>>
>>
>> David Villasmil
>>
>> email: david.villasmil.work at gmail.com
>>
>> phone: +34669448337
>>
>> --
>>
>> Regards,
>>
>>
>>
>> David Villasmil
>>
>> email: david.villasmil.work at gmail.com
>>
>> phone: +34669448337
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
> --
> Regards,
>
> David Villasmil
> email: david.villasmil.work at gmail.com
> phone: +34669448337
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20210602/4d6175ba/attachment-0001.html>


More information about the Users mailing list