-rw-r--r-- | lib/discovery.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/discovery.cc b/lib/discovery.cc index b4ed3b6..5585e12 100644 --- a/lib/discovery.cc +++ b/lib/discovery.cc | |||
@@ -91,65 +91,65 @@ namespace opkele { | |||
91 | pt_stack_t pt_stack; | 91 | pt_stack_t pt_stack; |
92 | int skipping; | 92 | int skipping; |
93 | bool parser_choked; | 93 | bool parser_choked; |
94 | string save_html; | 94 | string save_html; |
95 | 95 | ||
96 | XRD_t *xrd; | 96 | XRD_t *xrd; |
97 | service_t *xrd_service; | 97 | service_t *xrd_service; |
98 | string* cdata; | 98 | string* cdata; |
99 | 99 | ||
100 | idigger_t() | 100 | idigger_t() |
101 | : util::curl_t(easy_init()), | 101 | : util::curl_t(easy_init()), |
102 | util::expat_t(0), | 102 | util::expat_t(0), |
103 | xri_proxy(XRI_PROXY_URL) { | 103 | xri_proxy(XRI_PROXY_URL) { |
104 | CURLcode r; | 104 | CURLcode r; |
105 | (r=misc_sets()) | 105 | (r=misc_sets()) |
106 | || (r=set_write()) | 106 | || (r=set_write()) |
107 | || (r=set_header()) | 107 | || (r=set_header()) |
108 | ; | 108 | ; |
109 | if(r) | 109 | if(r) |
110 | throw exception_curl(OPKELE_CP_ "failed to set curly options",r); | 110 | throw exception_curl(OPKELE_CP_ "failed to set curly options",r); |
111 | } | 111 | } |
112 | ~idigger_t() throw() { } | 112 | ~idigger_t() throw() { } |
113 | 113 | ||
114 | void yadiscover(endpoint_discovery_iterator oi,const string& yurl,const char **types,bool redirs) { | 114 | void yadiscover(endpoint_discovery_iterator oi,const string& yurl,const char **types,bool redirs) { |
115 | idiscovery_t idis; | 115 | idiscovery_t idis; |
116 | idis.xri_identity = false; | 116 | idis.xri_identity = false; |
117 | discover_at(idis,yurl,xmode_html|xmode_xrd|(redirs?0:xmode_noredirs)); | 117 | discover_at(idis,yurl,xmode_html|xmode_xrd|(redirs?0:xmode_noredirs)); |
118 | if(!xrds_location.empty()) { | 118 | if(!xrds_location.empty()) { |
119 | idis.clear(); | 119 | idis.clear(); |
120 | discover_at(idis,xrds_location,xmode_xrd); | 120 | discover_at(idis,xrds_location,xmode_xrd); |
121 | } | 121 | } |
122 | idis.normalized_id = idis.canonicalized_id = yurl; | 122 | idis.normalized_id = idis.canonicalized_id = yurl; |
123 | service_type_t st; | 123 | service_type_t st = { 0, 0 }; |
124 | for(st.uri=*types;*types;st.uri=*(++types)) | 124 | for(st.uri=*types;*types;st.uri=*(++types)) |
125 | queue_endpoints(oi,idis,&st); | 125 | queue_endpoints(oi,idis,&st); |
126 | } | 126 | } |
127 | 127 | ||
128 | string discover(endpoint_discovery_iterator& oi,const string& identity) { | 128 | string discover(endpoint_discovery_iterator& oi,const string& identity) { |
129 | string rv; | 129 | string rv; |
130 | idiscovery_t idis; | 130 | idiscovery_t idis; |
131 | string::size_type fsc = identity.find_first_not_of(data::_whitespace_chars); | 131 | string::size_type fsc = identity.find_first_not_of(data::_whitespace_chars); |
132 | if(fsc==string::npos) | 132 | if(fsc==string::npos) |
133 | throw bad_input(OPKELE_CP_ "whitespace-only identity"); | 133 | throw bad_input(OPKELE_CP_ "whitespace-only identity"); |
134 | string::size_type lsc = identity.find_last_not_of(data::_whitespace_chars); | 134 | string::size_type lsc = identity.find_last_not_of(data::_whitespace_chars); |
135 | assert(lsc!=string::npos); | 135 | assert(lsc!=string::npos); |
136 | if(!strncasecmp(identity.c_str()+fsc,"xri://",sizeof("xri://")-1)) | 136 | if(!strncasecmp(identity.c_str()+fsc,"xri://",sizeof("xri://")-1)) |
137 | fsc += sizeof("xri://")-1; | 137 | fsc += sizeof("xri://")-1; |
138 | if((fsc+1)>=lsc) | 138 | if((fsc+1)>=lsc) |
139 | throw bad_input(OPKELE_CP_ "not a character of importance in identity"); | 139 | throw bad_input(OPKELE_CP_ "not a character of importance in identity"); |
140 | string id(identity,fsc,lsc-fsc+1); | 140 | string id(identity,fsc,lsc-fsc+1); |
141 | idis.clear(); | 141 | idis.clear(); |
142 | if(strchr(data::_iname_leaders,id[0])) { | 142 | if(strchr(data::_iname_leaders,id[0])) { |
143 | /* TODO: further normalize xri identity? Like folding case | 143 | /* TODO: further normalize xri identity? Like folding case |
144 | * or whatever... */ | 144 | * or whatever... */ |
145 | rv = id; | 145 | rv = id; |
146 | set<string> cids; | 146 | set<string> cids; |
147 | for(const struct service_type_t *st=op_service_types; | 147 | for(const struct service_type_t *st=op_service_types; |
148 | st<&op_service_types[sizeof(op_service_types)/sizeof(*op_service_types)];++st) { | 148 | st<&op_service_types[sizeof(op_service_types)/sizeof(*op_service_types)];++st) { |
149 | idis.clear(); | 149 | idis.clear(); |
150 | discover_at( idis, | 150 | discover_at( idis, |
151 | xri_proxy + util::url_encode(id)+ | 151 | xri_proxy + util::url_encode(id)+ |
152 | "?_xrd_t="+util::url_encode(st->uri)+ | 152 | "?_xrd_t="+util::url_encode(st->uri)+ |
153 | "&_xrd_r=application/xrd%2Bxml" | 153 | "&_xrd_r=application/xrd%2Bxml" |
154 | ";sep=true;refs=true", | 154 | ";sep=true;refs=true", |
155 | xmode_xrd ); | 155 | xmode_xrd ); |