def _strict_router_workaround(fwd_result): # The proxy MUST place the Request-URI into the Route header # field as the last value. sip_msg, opts = fwd_result route_hdr = sip_msg.get(ROUTE_HEADER) ruri_route = RouteHeader.make_route(sip_msg.ruri) route_hdr.route_set.add_last(ruri_route) # The proxy MUST then place the first Route header field value # into the Request-URI and remove that value from the Route # header field. sip_msg.ruri = route_hdr.route_set.first.uri route_hdr.route_set.remove_first() sip_msg.set(ROUTE_HEADER, route_hdr) return sip_msg, ForwardOptions(routing='strict')
def _fwd_record_route(target, fwd_result, proxy_params): """ Args: target: fwd_result: proxy_params (ProxyOptionsDetails): Returns: """ sip_msg, opts = fwd_result if proxy_params.record_route_uri is not None: rr = proxy_params.record_route_uri.clear_not_allowed_parts( RECORD_ROUTE_HEADER) rr.set_param(PARAM_LR, True) rrroute = RouteHeader.make_route(rr) rr_set = sip_msg.find(RECORD_ROUTE_HEADER) if isinstance(rr_set, NotFound): rr_set = RouteHeader() rr_set.route_set.add_first(rrroute) sip_msg.set(RECORD_ROUTE_HEADER, rr_set) return sip_msg, opts