aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGertjan van den Burg <gertjanvandenburg@gmail.com>2020-10-27 22:52:07 +0100
committerGertjan van den Burg <gertjanvandenburg@gmail.com>2020-10-27 22:52:07 +0100
commit2d861cf40ce62c1445f15c57af65f80424cc5f91 (patch)
tree2cb73a14499316d88e6b3292bcb3c183365c164f
parentBugfix for content type detection (diff)
parentUse a cookiejar instead of empty dict (diff)
downloadpaper2remarkable-2d861cf40ce62c1445f15c57af65f80424cc5f91.tar.gz
paper2remarkable-2d861cf40ce62c1445f15c57af65f80424cc5f91.zip
Merge branch 'master' into bugfix/content_type
-rw-r--r--paper2remarkable/utils.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/paper2remarkable/utils.py b/paper2remarkable/utils.py
index 573e010..09082a5 100644
--- a/paper2remarkable/utils.py
+++ b/paper2remarkable/utils.py
@@ -90,7 +90,10 @@ def get_page_with_retry(url, tries=5, cookiejar=None, return_text=False):
def get_content_type_with_retry(url, tries=5, cookiejar=None):
count = 0
- jar = {} if cookiejar is None else cookiejar
+ if cookiejar is None:
+ jar = requests.cookies.RequestsCookieJar()
+ else:
+ jar = cookiejar
while count < tries:
count += 1
error = False
@@ -135,7 +138,7 @@ def get_content_type_with_retry(url, tries=5, cookiejar=None):
def follow_redirects(url):
"""Follow redirects from the URL (at most 100)"""
it = 0
- jar = {}
+ jar = requests.cookies.RequestsCookieJar()
while it < 100:
req = requests.head(
url, headers=HEADERS, allow_redirects=False, cookies=jar