Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParseURL should have reasonable timeout #83

Open
cjacques1 opened this issue Nov 2, 2017 · 1 comment
Open

ParseURL should have reasonable timeout #83

cjacques1 opened this issue Nov 2, 2017 · 1 comment

Comments

@cjacques1
Copy link

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

@peteretelej
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants