summaryrefslogtreecommitdiffabout
path: root/lib/discovery.cc
Unidiff
Diffstat (limited to 'lib/discovery.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/discovery.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/discovery.cc b/lib/discovery.cc
index d1989ec..984e308 100644
--- a/lib/discovery.cc
+++ b/lib/discovery.cc
@@ -330,25 +330,25 @@ namespace opkele {
330 } 330 }
331 size_t header(void *p,size_t s,size_t nm) { 331 size_t header(void *p,size_t s,size_t nm) {
332 size_t bytes = s*nm; 332 size_t bytes = s*nm;
333 const char *h = (const char*)p; 333 const char *h = (const char*)p;
334 const char *colon = (const char*)memchr(p,':',bytes); 334 const char *colon = (const char*)memchr(p,':',bytes);
335 const char *space = (const char*)memchr(p,' ',bytes); 335 const char *space = (const char*)memchr(p,' ',bytes);
336 if(space && ( (!colon) || space<colon ) ) { 336 if(space && ( (!colon) || space<colon ) ) {
337 xrds_location.clear(); http_content_type.clear(); 337 xrds_location.clear(); http_content_type.clear();
338 }else if(colon) { 338 }else if(colon) {
339 const char *hv = ++colon; 339 const char *hv = ++colon;
340 size_t hnl = colon-h; 340 size_t hnl = colon-h;
341 int rb; 341 int rb;
342 for(rb = bytes-hnl-1;rb>0 && isspace(*hv);++hv,--rb); 342 for(rb = bytes-hnl-1;rb>0 && isspace(*hv);++hv,--rb) ;
343 while(rb>0 && isspace(hv[rb-1])) --rb; 343 while(rb>0 && isspace(hv[rb-1])) --rb;
344 if(rb) { 344 if(rb) {
345 if( (hnl>=sizeof(XRDS_HEADER)) 345 if( (hnl>=sizeof(XRDS_HEADER))
346 && !strncasecmp(h,XRDS_HEADER":", 346 && !strncasecmp(h,XRDS_HEADER":",
347 sizeof(XRDS_HEADER)) ) { 347 sizeof(XRDS_HEADER)) ) {
348 xrds_location.assign(hv,rb); 348 xrds_location.assign(hv,rb);
349 }else if( (hnl>=sizeof(CT_HEADER)) 349 }else if( (hnl>=sizeof(CT_HEADER))
350 && !strncasecmp(h,CT_HEADER":", 350 && !strncasecmp(h,CT_HEADER":",
351 sizeof(CT_HEADER)) ) { 351 sizeof(CT_HEADER)) ) {
352 const char *sc = (const char*)memchr( 352 const char *sc = (const char*)memchr(
353 hv,';',rb); 353 hv,';',rb);
354 http_content_type.assign(hv,sc?(sc-hv):rb); 354 http_content_type.assign(hv,sc?(sc-hv):rb);
@@ -491,25 +491,25 @@ namespace opkele {
491 l.assign(a[1]); 491 l.assign(a[1]);
492 } 492 }
493 if(heq) 493 if(heq)
494 xrds_location = l; 494 xrds_location = l;
495 }else if(is_element(n,"link")) { 495 }else if(is_element(n,"link")) {
496 string rels; 496 string rels;
497 string href; 497 string href;
498 for(;*a;a+=2) { 498 for(;*a;a+=2) {
499 if( !strcasecmp(a[0],"rel") ) { 499 if( !strcasecmp(a[0],"rel") ) {
500 rels.assign(a[1]); 500 rels.assign(a[1]);
501 }else if( !strcasecmp(a[0],"href") ) { 501 }else if( !strcasecmp(a[0],"href") ) {
502 const char *ns = a[1]; 502 const char *ns = a[1];
503 for(;*ns && isspace(*ns);++ns); 503 for(;*ns && isspace(*ns);++ns) ;
504 href.assign(ns); 504 href.assign(ns);
505 string::size_type lns=href.find_last_not_of(data::_whitespace_chars); 505 string::size_type lns=href.find_last_not_of(data::_whitespace_chars);
506 href.erase(lns+1); 506 href.erase(lns+1);
507 } 507 }
508 } 508 }
509 for(string::size_type ns=rels.find_first_not_of(data::_whitespace_chars); 509 for(string::size_type ns=rels.find_first_not_of(data::_whitespace_chars);
510 ns!=string::npos; ns=rels.find_first_not_of(data::_whitespace_chars,ns)) { 510 ns!=string::npos; ns=rels.find_first_not_of(data::_whitespace_chars,ns)) {
511 string::size_type s = rels.find_first_of(data::_whitespace_chars,ns); 511 string::size_type s = rels.find_first_of(data::_whitespace_chars,ns);
512 string rel; 512 string rel;
513 if(s==string::npos) { 513 if(s==string::npos) {
514 rel.assign(rels,ns,string::npos); 514 rel.assign(rels,ns,string::npos);
515 ns = string::npos; 515 ns = string::npos;