for name, digest := range forHTTP.Hashes {
w.Header().Add("Digest", name+"="+base64.StdEncoding.EncodeToString(digest))
}
+ for _, u := range forHTTP.Torrents {
+ w.Header().Add("Link", "<"+u+`>; rel=describedby; type="application/x-bittorrent"`)
+ }
}
SkipMeta4:
type ForHTTP struct {
Hashes map[string][]byte
URLs []string
+ Torrents []string
}
func Parse(fn string, data []byte) (*ForHTTP, error) {
for _, u := range f.URLs {
forHTTP.URLs = append(forHTTP.URLs, u.URL)
}
+ for _, m := range f.MetaURLs {
+ if m.MediaType == "torrent" {
+ forHTTP.Torrents = append(forHTTP.Torrents, m.URL)
+ }
+ }
return &forHTTP, nil
}
return nil, nil