summaryrefslogtreecommitdiffabout
path: root/lib/discovery.cc
authorMichael Krelin <hacker@klever.net>2007-12-26 21:55:00 (UTC)
committer Michael Krelin <hacker@klever.net>2008-01-04 18:16:31 (UTC)
commite63de16a9885641b5070ec834225cb562bc2042f (patch) (side-by-side diff)
treeb50a7c202aaa6953dd47402fc60f53ac4a57cf62 /lib/discovery.cc
parentac9e3ddb4277e5696d789ad6b3ea7aa820a5e76a (diff)
downloadlibopkele-e63de16a9885641b5070ec834225cb562bc2042f.zip
libopkele-e63de16a9885641b5070ec834225cb562bc2042f.tar.gz
libopkele-e63de16a9885641b5070ec834225cb562bc2042f.tar.bz2
fix the xrds_location being cleared before it gets used.
The xrds_location should not be cleared when doing pure xrd discovery. Otherwise it may get overwritten before curl actually uses it. Previously it was cleared twice, which is a waste of cpu cycles, anyway. Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'lib/discovery.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/discovery.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/discovery.cc b/lib/discovery.cc
index 9503b5d..ea53786 100644
--- a/lib/discovery.cc
+++ b/lib/discovery.cc
@@ -115,65 +115,65 @@ namespace opkele {
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())
html2xrd(result.xrd);
}
}
}
void discover_at(idiscovery_t& result,const string& url,int xm) {
CURLcode r = easy_setopt(CURLOPT_URL,url.c_str());
if(r)
throw exception_curl(OPKELE_CP_ "failed to set culry urlie",r);
(*(expat_t*)this) = parser_create_ns();
set_user_data(); set_element_handler();
set_character_data_handler();
- xrds_location.clear(); http_content_type.clear();
+ http_content_type.clear();
xmode = xm;
if(xmode&xmode_html) {
xrds_location.clear();
html_openid1.clear(); html_openid2.clear();
}
xrd = &result.xrd;
cdata = 0; xrd_service = 0; skipping = 0;
status_code = 100; status_string.clear();
r = easy_perform();
if(r && r!=CURLE_WRITE_ERROR)
throw exception_curl(OPKELE_CP_ "failed to perform curly request",r);
parse(0,0,true);
}
void html2xrd(XRD_t& x) {
if(!html_openid1.uris.empty()) {
html_openid1.types.insert(STURI_OPENID11);
x.services.add(-1,html_openid1);
}
if(!html_openid2.uris.empty()) {
html_openid2.types.insert(STURI_OPENID20);
x.services.add(-1,html_openid2);
}
}
size_t write(void *p,size_t s,size_t nm) {
if(skipping<0) return 0;
/* TODO: limit total size */
size_t bytes = s*nm;
parse((const char *)p,bytes,false);