summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2007-12-29 21:26:53 (UTC)
committer Michael Krelin <hacker@klever.net>2008-01-04 18:22:12 (UTC)
commit9020dcc4b8187a9dd31c62dbe89041772b0f5473 (patch) (side-by-side diff)
treed04da68e1c01a687834525437487364de53a6ad2
parent3801123163d78896a05fb26323deb7c0fa8c7f8e (diff)
downloadlibopkele-9020dcc4b8187a9dd31c62dbe89041772b0f5473.zip
libopkele-9020dcc4b8187a9dd31c62dbe89041772b0f5473.tar.gz
libopkele-9020dcc4b8187a9dd31c62dbe89041772b0f5473.tar.bz2
xri discovery fills in canonicalized_id for xri identities now
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--lib/discovery.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/discovery.cc b/lib/discovery.cc
index 3b184ee..bc7d6fb 100644
--- a/lib/discovery.cc
+++ b/lib/discovery.cc
@@ -83,48 +83,49 @@ namespace opkele {
result.clear();
string::size_type fsc = identity.find_first_not_of(whitespace);
if(fsc==string::npos)
throw bad_input(OPKELE_CP_ "whtiespace-only identity");
string::size_type lsc = identity.find_last_not_of(whitespace);
assert(lsc!=string::npos);
if(!strncasecmp(identity.c_str()+fsc,"xri://",sizeof("xri://")-1))
fsc += sizeof("xri://")-1;
if((fsc+1)>=lsc)
throw bad_input(OPKELE_CP_ "not a character of importance in identity");
string id(identity,fsc,lsc-fsc+1);
if(strchr(i_leaders,id[0])) {
result.normalized_id = id;
result.xri_identity = true;
/* TODO: further canonicalize xri identity? Like folding case or whatever... */
discover_at(
result,
xri_proxy + util::url_encode(id)+
"?_xrd_r=application/xrd+xml;sep=false", xmode_xrd);
if(status_code!=100)
throw failed_xri_resolution(OPKELE_CP_
"XRI resolution failed with '"+status_string+"' message",status_code);
if(result.xrd.canonical_ids.empty())
throw opkele::failed_discovery(OPKELE_CP_ "No CanonicalID for XRI identity found");
+ result.canonicalized_id = result.xrd.canonical_ids.begin()->second;
}else{
result.xri_identity = false;
if(id.find("://")==string::npos)
id.insert(0,"http://");
string::size_type fp = id.find('#');
if(fp!=string::npos) {
string::size_type qp = id.find('?');
if(qp==string::npos || qp<fp)
id.erase(fp);
else if(qp>fp)
id.erase(fp,qp-fp);
}
result.normalized_id = util::rfc_3986_normalize_uri(id);
discover_at(result,id,xmode_html|xmode_xrd);
const char * eu = 0;
CURLcode r = easy_getinfo(CURLINFO_EFFECTIVE_URL,&eu);
if(r)
throw exception_curl(OPKELE_CP_ "failed to get CURLINFO_EFFECTIVE_URL",r);
result.canonicalized_id = util::rfc_3986_normalize_uri(eu); /* XXX: strip fragment part? */
if(xrds_location.empty()) {
html2xrd(result.xrd);
}else{
discover_at(result,xrds_location,xmode_xrd);
if(result.xrd.empty())