mirror of
https://github.com/ihabunek/toot.git
synced 2025-02-02 15:07:51 -05:00
Set the user agent string to all requests
Fixes issue with accessing instances using Cloudfare DDOS protection. issue #106
This commit is contained in:
parent
07a01df941
commit
840b2fd476
@ -1,9 +1,14 @@
|
|||||||
from requests import Request, Session
|
from requests import Request, Session
|
||||||
|
from toot import __version__
|
||||||
from toot.exceptions import NotFoundError, ApiError
|
from toot.exceptions import NotFoundError, ApiError
|
||||||
from toot.logging import log_request, log_response
|
from toot.logging import log_request, log_response
|
||||||
|
|
||||||
|
|
||||||
def send_request(request, allow_redirects=True):
|
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)
|
log_request(request)
|
||||||
|
|
||||||
with Session() as session:
|
with Session() as session:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user