gofeed
gofeed copied to clipboard
ParseURL should have reasonable timeout
Expected behavior
If the connection to the given url is hanging, the httpClient should timeout. Ideally the desired timeout could be an argument with a reasonable default
Actual behavior
the connection hangs
Steps to reproduce the behavior
find a url with really slow network and try parsing it.
Note: Please include any links to problem feeds, or the feed content itself! the link that hung for me was http://rss.shanghaidaily.com/Portal/mainSite/Handler.ashx?i=7
the function that's hanging for me is ParseURL in parser.go
set your desired timeout on the parser's client:
fp := gofeed.NewParser()
fp.Client = &http.Client{ Timeout: time.Second*10 }
feed, _ := fp.ParseURL("http://feeds.twit.tv/twit.xml")
fmt.Println(feed.Title)