Set the user agent string to all requests

Fixes issue with accessing instances using Cloudfare DDOS protection.

issue #106
This commit is contained in:
Ivan Habunek 2019-08-07 22:58:30 +02:00
parent 07a01df941
commit 840b2fd476
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95
1 changed files with 5 additions and 0 deletions

View File

@ -1,9 +1,14 @@
from requests import Request, Session
from toot import __version__
from toot.exceptions import NotFoundError, ApiError
from toot.logging import log_request, log_response
def send_request(request, allow_redirects=True):
# Set a user agent string
# Required for accesing instances using Cloudfront DDOS protection.
request.headers["User-Agent"] = "toot/{}".format(__version__)
log_request(request)
with Session() as session: