summaryrefslogtreecommitdiffabout
path: root/lib
authorMichael Krelin <hacker@klever.net>2008-02-22 12:33:42 (UTC)
committer Michael Krelin <hacker@klever.net>2008-02-22 12:33:42 (UTC)
commit4c9564dce14fdc46ef6739426ee1cad87ed58ad1 (patch) (unidiff)
tree6f1f520d56b5e346abb6bf9514b697c7e2240819 /lib
parentdaf2d4bcb4a31df6b46d3da7a33ee3f98d85e464 (diff)
downloadlibopkele-4c9564dce14fdc46ef6739426ee1cad87ed58ad1.zip
libopkele-4c9564dce14fdc46ef6739426ee1cad87ed58ad1.tar.gz
libopkele-4c9564dce14fdc46ef6739426ee1cad87ed58ad1.tar.bz2
fix the discovery for the case when identity URL points to XRDS document.
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'lib') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/discovery.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/discovery.cc b/lib/discovery.cc
index 5913ad4..c118c80 100644
--- a/lib/discovery.cc
+++ b/lib/discovery.cc
@@ -179,49 +179,55 @@ namespace opkele {
179 idis.canonicalized_id = cid; 179 idis.canonicalized_id = cid;
180 idis.normalized_id = rv; idis.xri_identity = true; 180 idis.normalized_id = rv; idis.xri_identity = true;
181 queue_endpoints(oi,idis,st); 181 queue_endpoints(oi,idis,st);
182 } 182 }
183 }else{ 183 }else{
184 idis.xri_identity = false; 184 idis.xri_identity = false;
185 if(id.find("://")==string::npos) 185 if(id.find("://")==string::npos)
186 id.insert(0,"http://"); 186 id.insert(0,"http://");
187 string::size_type fp = id.find('#'); 187 string::size_type fp = id.find('#');
188 if(fp!=string::npos) { 188 if(fp!=string::npos) {
189 string::size_type qp = id.find('?'); 189 string::size_type qp = id.find('?');
190 if(qp==string::npos || qp<fp) 190 if(qp==string::npos || qp<fp)
191 id.erase(fp); 191 id.erase(fp);
192 else if(qp>fp) 192 else if(qp>fp)
193 id.erase(fp,qp-fp); 193 id.erase(fp,qp-fp);
194 } 194 }
195 rv = idis.normalized_id = util::rfc_3986_normalize_uri(id); 195 rv = idis.normalized_id = util::rfc_3986_normalize_uri(id);
196 discover_at(idis,id,xmode_html|xmode_xrd); 196 discover_at(idis,id,xmode_html|xmode_xrd);
197 const char * eu = 0; 197 const char * eu = 0;
198 CURLcode r = easy_getinfo(CURLINFO_EFFECTIVE_URL,&eu); 198 CURLcode r = easy_getinfo(CURLINFO_EFFECTIVE_URL,&eu);
199 if(r) 199 if(r)
200 throw exception_curl(OPKELE_CP_ "failed to get CURLINFO_EFFECTIVE_URL",r); 200 throw exception_curl(OPKELE_CP_ "failed to get CURLINFO_EFFECTIVE_URL",r);
201 string cid = util::strip_uri_fragment_part( idis.canonicalized_id = util::rfc_3986_normalize_uri(eu) ); 201 string cid = util::strip_uri_fragment_part( idis.canonicalized_id = util::rfc_3986_normalize_uri(eu) );
202 if(xrds_location.empty()) { 202 if(xrds_location.empty()) {
203 html2xrd(oi,idis); 203 if(idis.xrd.empty())
204 html2xrd(oi,idis);
205 else{
206 for(const service_type_t *st=op_service_types;
207 st<&op_service_types[sizeof(op_service_types)/sizeof(*op_service_types)];++st)
208 queue_endpoints(oi,idis,st);
209 }
204 }else{ 210 }else{
205 idis.clear(); 211 idis.clear();
206 idis.canonicalized_id = cid; 212 idis.canonicalized_id = cid;
207 discover_at(idis,xrds_location,xmode_xrd); 213 discover_at(idis,xrds_location,xmode_xrd);
208 if(idis.xrd.empty()) 214 if(idis.xrd.empty())
209 html2xrd(oi,idis); 215 html2xrd(oi,idis);
210 else{ 216 else{
211 for(const service_type_t *st=op_service_types; 217 for(const service_type_t *st=op_service_types;
212 st<&op_service_types[sizeof(op_service_types)/sizeof(*op_service_types)];++st) 218 st<&op_service_types[sizeof(op_service_types)/sizeof(*op_service_types)];++st)
213 queue_endpoints(oi,idis,st); 219 queue_endpoints(oi,idis,st);
214 } 220 }
215 } 221 }
216 } 222 }
217 return rv; 223 return rv;
218 } 224 }
219 225
220 void discover_at(idiscovery_t& idis,const string& url,int xm) { 226 void discover_at(idiscovery_t& idis,const string& url,int xm) {
221 CURLcode r = easy_setopt(CURLOPT_MAXREDIRS, (xm&xmode_noredirs)?0:5); 227 CURLcode r = easy_setopt(CURLOPT_MAXREDIRS, (xm&xmode_noredirs)?0:5);
222 if(r) 228 if(r)
223 throw exception_curl(OPKELE_CP_ "failed to set curly maxredirs option"); 229 throw exception_curl(OPKELE_CP_ "failed to set curly maxredirs option");
224 if( (r=easy_setopt(CURLOPT_URL,url.c_str())) ) 230 if( (r=easy_setopt(CURLOPT_URL,url.c_str())) )
225 throw exception_curl(OPKELE_CP_ "failed to set curly urlie",r); 231 throw exception_curl(OPKELE_CP_ "failed to set curly urlie",r);
226 232
227 http_content_type.clear(); 233 http_content_type.clear();