// Fetch retrieves the feed's content from the []byte // // The charset parameter overrides the xml decoder's CharsetReader. // This allows us to specify a custom character encoding conversion // routine when dealing with non-utf8 input. Supply 'nil' to use the // default from Go's xml package. func (this *Feed) FetchBytes(uri string, content []byte, charset xmlx.CharsetFunc) (err error) { this.Url = uri doc := xmlx.New() if err = doc.LoadBytes(content, charset); err != nil { return } return this.makeFeed(doc) }
// Fetch retrieves the feed's latest content if necessary. // // The charset parameter overrides the xml decoder's CharsetReader. // This allows us to specify a custom character encoding conversion // routine when dealing with non-utf8 input. Supply 'nil' to use the // default from Go's xml package. // // The client parameter allows the use of arbitrary network connections, for // example the Google App Engine "URL Fetch" service. func (this *Feed) FetchClient(uri string, client *http.Client, charset xmlx.CharsetFunc) (err error) { if !this.CanUpdate() { return } this.lastupdate = time.Now().UTC() this.Url = uri doc := xmlx.New() if len(this.userAgent) > 1 { doc.SetUserAgent(this.userAgent) } if err = doc.LoadUriClient(uri, client, charset); err != nil { return } if err = this.makeFeed(doc); err == nil { // Only if fetching and parsing succeeded. this.ignoreCacheOnce = false } return }