summaryrefslogtreecommitdiffabout
path: root/lib
authorMichael Krelin <hacker@klever.net>2007-12-13 18:33:20 (UTC)
committer Michael Krelin <hacker@klever.net>2007-12-13 18:37:33 (UTC)
commit58383f07af80dfd5b5c18e5158291c3d8caefbe7 (patch) (unidiff)
treefe7b9bc8da74bce0dcc6d8a033b8a8073f81ad14 /lib
parent54f9cf0424f47ef6384bc55904097dc4ecb5fc78 (diff)
downloadlibopkele-58383f07af80dfd5b5c18e5158291c3d8caefbe7.zip
libopkele-58383f07af80dfd5b5c18e5158291c3d8caefbe7.tar.gz
libopkele-58383f07af80dfd5b5c18e5158291c3d8caefbe7.tar.bz2
keep track of whether the identity being discovered is XRI
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'lib') (more/less context) (show whitespace changes)
-rw-r--r--lib/discovery.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/discovery.cc b/lib/discovery.cc
index a35ce32..1f23ff1 100644
--- a/lib/discovery.cc
+++ b/lib/discovery.cc
@@ -92,23 +92,25 @@ namespace opkele {
92 fsc += sizeof("xri://")-1; 92 fsc += sizeof("xri://")-1;
93 if((fsc+1)>=lsc) 93 if((fsc+1)>=lsc)
94 throw bad_input(OPKELE_CP_ "not a character of importance in identity"); 94 throw bad_input(OPKELE_CP_ "not a character of importance in identity");
95 string id(identity,fsc,lsc-fsc+1); 95 string id(identity,fsc,lsc-fsc+1);
96 if(strchr(i_leaders,id[0])) { 96 if(strchr(i_leaders,id[0])) {
97 result.normalized_id = id; 97 result.normalized_id = id;
98 result.xri_identity = true;
98 /* TODO: further canonicalize xri identity? Like folding case or whatever... */ 99 /* TODO: further canonicalize xri identity? Like folding case or whatever... */
99 discover_at( 100 discover_at(
100 result, 101 result,
101 xri_proxy + util::url_encode(id)+ 102 xri_proxy + util::url_encode(id)+
102 "?_xrd_r=application/xrd+xml;sep=false", xmode_xrd); 103 "?_xrd_r=application/xrd+xml;sep=false", xmode_xrd);
103 if(status_code!=100) 104 if(status_code!=100)
104 throw failed_xri_resolution(OPKELE_CP_ 105 throw failed_xri_resolution(OPKELE_CP_
105 "XRI resolution failed with '"+status_string+"' message",status_code); 106 "XRI resolution failed with '"+status_string+"' message",status_code);
106 if(result.xrd.canonical_ids.empty()) 107 if(result.xrd.canonical_ids.empty())
107 throw opkele::failed_discovery(OPKELE_CP_ "No CanonicalID for XRI identity found"); 108 throw opkele::failed_discovery(OPKELE_CP_ "No CanonicalID for XRI identity found");
108 }else{ 109 }else{
110 result.xri_identity = false;
109 if(id.find("://")==string::npos) 111 if(id.find("://")==string::npos)
110 id.insert(0,"http://"); 112 id.insert(0,"http://");
111 string::size_type fp = id.find('#'); 113 string::size_type fp = id.find('#');
112 if(fp!=string::npos) { 114 if(fp!=string::npos) {
113 string::size_type qp = id.find('?'); 115 string::size_type qp = id.find('?');
114 if(qp==string::npos || qp<fp) 116 if(qp==string::npos || qp<fp)