if (code==401) wah=msg.getWwwAuthenticateHeader();
else wah=msg.getProxyAuthenticateHeader();
String qop_options=wah.getQopOptionsParam();
qop=(qop_options!=null)? "auth" : null;
RequestLine rl=req.getRequestLine();
DigestAuthentication digest=new DigestAuthentication(rl.getMethod(),rl.getAddress().toString(),wah,qop,null,username,passwd);
AuthorizationHeader ah;
if (code==401) ah=digest.getAuthorizationHeader();
else ah=digest.getProxyAuthorizationHeader();
req.setAuthorizationHeader(ah);
if (req.isInvite()) // make sure it's an invite
this.invite_req=req; // must track last invite so cancel will work correctly - fixes 503 from asterisk on cancel