quakkels / rssdiscoveryengine

The RSS Discovery Engine exists to encourage people to use RSS for finding and consuming their news and current events.
MIT License
159 stars 9 forks source link

Ensure that the User-Agent header is always present when making HTTP requests #8

Closed lewiscollard closed 3 years ago

lewiscollard commented 3 years ago

RSS Discovery Engine does HTTP requests in several different ways:

1) aiohttp 2) the get_response_content function 3) the get_request function 4) whatever feedparser uses internally

Only get_request was setting the User-Agent header. Not setting a user agent (or using the default one from the lib) is a fairly reliable way to trip bad-bot-detection alarms; I am reasonably sure this is part of why it struggles to work with HN.

This changeset ensures that it always sets the header, however the request is made.

Driveby: order some imports and remove an unused one.