aboutsummaryrefslogtreecommitdiffstats
path: root/generated by cgit v1.2.3 (git 2.39.1) at 2025-07-25 19:14:08 +0000
ype // response-header specifying MIME media type, // application/xrds+xml, or both. // (this is handled by one of the 2 previous if statements) return "", "", errors.New("No expected header, or content type") } // Similar as above, but we expect an absolute Yadis document URL. func getYadisResourceDescriptor(id string, getter httpGetter) (opEndpoint string, opLocalID string, err error) { resp, err := getter.Get(id, yadisHeaders) if err != nil { return "", "", err } defer resp.Body.Close() // 4. A document of MIME media type, application/xrds+xml. body, err := ioutil.ReadAll(resp.Body) if err == nil { return parseXrds(body) } return "", "", err } // Search for // <head> // <meta http-equiv="X-XRDS-Location" content="...."> func findMetaXrdsLocation(input io.Reader) (location string, err error) { tokenizer := html.NewTokenizer(input) inHead := false for { tt := tokenizer.Next() switch tt { case html.ErrorToken: return "", tokenizer.Err() case html.StartTagToken, html.EndTagToken: tk := tokenizer.Token() if tk.Data == "head" { if tt == html.StartTagToken { inHead = true } else { return "", errors.New("Meta X-XRDS-Location not found") } } else if inHead && tk.Data == "meta" { ok := false content := "" for _, attr := range tk.Attr { if attr.Key == "http-equiv" && strings.ToLower(attr.Val) == "x-xrds-location" { ok = true } else if attr.Key == "content" { content = attr.Val } } if ok && len(content) > 0 { return content, nil } } } } return "", errors.New("Meta X-XRDS-Location not found") }