anchor.diff:  	    transactionlayer:send_response_handler(THandler, 500, "Server Internal Error")
       end.
   
  -
  -%% Function: route_request/1
  -%% Description: Check if a request is destined for this proxy, a local
  -%%              domain or a remote domain. In case of a local domain,
  -%%              we call request_to_homedomain(), and in case of a
  -%%              remote domain we call request_to_remote(). If these
  -%%              functions return 'nomatch' we call lookupdefault().
  -%% Returns: {error, Status}            |
  -%%          {response, Status, Reason} |
  -%%          {proxy, Location}          |
  -%%          {relay, Location}          |
  -%%          {forward, Location}        |
  -%%          {me}                       |
  -%%          none
  -%%--------------------------------------------------------------------
  -route_request(Request) when record(Request, request) ->
  -    {Method, URL, Header} = {Request#request.method, Request#request.uri, Request#request.header},
  +%%--------------------------------------------------------------------
  +%% Function: route_request(Request)
  +%%           Request = request record()
  +%% Descrip.: Check if a request is destined for this proxy, a local
  +%%           domain or a remote domain. In case of a local domain,
  +%%           we call request_to_homedomain(), and in case of a
  +%%           remote domain we call request_to_remote(). If these
  +%%           functions return 'nomatch' we call lookupdefault().
  +%% Returns : {error, Status}            |
  +%%           {response, Status, Reason} |
  +%%           {proxy, Location}          |
  +%%           {relay, Location}          |
  +%%           {forward, Location}        |
  +%%           {me}                       |
  +%%           none
  +%%--------------------------------------------------------------------
  +route_request(Request) when is_record(Request, request) ->
  +    URL = Request#request.uri,
       case keylist:fetch("Route", Request#request.header) of
   	[] ->
   	    Loc1 = case local:homedomain(URL#sipurl.host) of
  
positive.code: 	{response, Status, Reason} ->
  	    logger:log(normal, "~s: incomingproxy: Response ~p ~s", [LogTag, Status, Reason]),
  	    transactionlayer:send_response_handler(THandler, Status, Reason);
  	{proxy, Loc} when record(Loc, sipurl) ->
  	    logger:log(normal, "~s: incomingproxy: Proxy ~s -> ~s", [LogTag, Method, sipurl:print(Loc)]),
  	    proxy_request(THandler, Request, Loc);
  	{redirect, Loc} when record(Loc, sipurl) ->
  	    logger:log(normal, "~s: incomingproxy: Redirect ~s", [LogTag, sipurl:print(Loc)]),
  	    Contact = [{none, Loc}],
  	    ExtraHeaders = [{"Contact", sipheader:contact_print(Contact)}],
  	    transactionlayer:send_response_handler(THandler, 302, "Moved Temporarily", ExtraHeaders);
  	{relay, Loc} ->
  	    relay_request(THandler, Request, Loc, Origin, LogTag);
  	{forward, FwdURL} when record(FwdURL, sipurl), FwdURL#sipurl.user == none, FwdURL#sipurl.pass == none ->
  	    logger:log(normal, "~s: incomingproxy: Forward ~s ~s to ~s",
  			[LogTag, Method, sipurl:print(URI), sipurl:print(FwdURL)]),
  	    {ok, _, ApproxMsgSize} = siprequest:check_proxy_request(Request),
  	    case sipdst:url_to_dstlist(FwdURL, ApproxMsgSize, URI) of
  		{error, nxdomain} ->
  		    logger:log(debug, "incomingproxy: Failed resolving FwdURL : NXDOMAIN (responding '604 Does Not Exist Anywhere')"),
                      transactionlayer:send_response_handler(THandler, 604, "Does Not Exist Anywhere"),
                      error;
  		{error, What} ->
  		    logger:log(normal, "incomingproxy: Failed resolving FwdURL : ~p", [What]),
                      transactionlayer:send_response_handler(THandler, 500, "Failed resolving forward destination"),
                      error;
  		DstList when list(DstList) ->
  		    proxy_request(THandler, Request, DstList)
  	    end;
  	{me} ->
  
negative.code:             case local:incomingproxy_challenge_before_relay(Origin, Request, Dst) of
                  false ->
                      logger:log(debug, "Relay: Failed authentication, but local policy says we should not challenge"),
                      sippipe:start(THandler, none, Request, Dst, 900);
                  _ ->
  		    logger:log(debug, "Relay: Failed authentication, sending challenge"),
  		    logger:log(normal, "~s: incomingproxy: Relay ~s -> 407 Proxy Authorization Required",
  			       [LogTag, relay_dst2str(Dst)]),
  		    transactionlayer:send_challenge(THandler, proxy, false, none)
  	    end;
  	Unknown ->
  