From 840b2fd476b83124914c3f252117fe4bb45f90b0 Mon Sep 17 00:00:00 2001 From: Ivan Habunek Date: Wed, 7 Aug 2019 22:58:30 +0200 Subject: [PATCH] Set the user agent string to all requests Fixes issue with accessing instances using Cloudfare DDOS protection. issue #106 --- toot/http.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/toot/http.py b/toot/http.py index b5b6839..a325b72 100644 --- a/toot/http.py +++ b/toot/http.py @@ -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: