diff --git a/atom.go b/atom.go index 27aaa15..fd59217 100644 --- a/atom.go +++ b/atom.go @@ -1,6 +1,6 @@ package feeder -import xmlx "github.com/jteeuwen/go-pkg-xmlx" +import xmlx "github.com/anschelsc/go-pkg-xmlx" func (this *Feed) readAtom(doc *xmlx.Document) (err error) { ns := "http://www.w3.org/2005/Atom" diff --git a/feed.go b/feed.go index 67aefa8..7592a36 100644 --- a/feed.go +++ b/feed.go @@ -1,6 +1,6 @@ /* Author: jim teeuwen - Dependencies: go-pkg-xmlx (http://github.com/jteeuwen/go-pkg-xmlx) + Dependencies: go-pkg-xmlx (http://github.com/anschelsc/go-pkg-xmlx) This package allows us to fetch Rss and Atom feeds from the internet. They are parsed into an object tree which is a hyvrid of both the RSS and Atom @@ -28,7 +28,8 @@ package feeder import ( "errors" "fmt" - xmlx "github.com/jteeuwen/go-pkg-xmlx" + xmlx "github.com/anschelsc/go-pkg-xmlx" + "net/http" "strconv" "strings" "time" @@ -90,7 +91,22 @@ func (this *Feed) LastUpdate() int64 { return this.lastupdate } // 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. +// +// This is equivalent to calling FetchClient with http.DefaultClient func (this *Feed) Fetch(uri string, charset xmlx.CharsetFunc) (err error) { + return this.FetchClient(uri, http.DefaultClient, charset) +} + +// 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 } @@ -101,7 +117,7 @@ func (this *Feed) Fetch(uri string, charset xmlx.CharsetFunc) (err error) { // function parse it (rss 0.91, rss 0.92, rss 2, atom etc). doc := xmlx.New() - if err = doc.LoadUri(uri, charset); err != nil { + if err = doc.LoadUriClient(uri, client, charset); err != nil { return } this.Type, this.Version = this.GetVersionInfo(doc) diff --git a/rss.go b/rss.go index c32ac61..cb71765 100644 --- a/rss.go +++ b/rss.go @@ -1,6 +1,6 @@ package feeder -import xmlx "github.com/jteeuwen/go-pkg-xmlx" +import xmlx "github.com/anschelsc/go-pkg-xmlx" func (this *Feed) readRss2(doc *xmlx.Document) (err error) { days := make(map[string]int)