Skip to content

Commit 040f22b

Browse files
committed
Adding User-Agent and Cache-Control headers
1 parent facef89 commit 040f22b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

bin/stashcp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ def get_best_stashcache():
247247
# Append text before caches string
248248
append_text = "api/v1.0/geo/stashcp"
249249

250+
# Headers for the HTTP request
251+
headers = {'Cache-control': 'max-age=0', 'User-Agent': 'stashcp/4.1'}
252+
250253
# Randomize the geo ip sites
251254
random.shuffle(geo_ip_sites)
252255
found = False
@@ -258,8 +261,7 @@ def get_best_stashcache():
258261
logging.debug("Querying for closest cache: %s", final_url)
259262
try:
260263
# Make the request
261-
req = urllib2.Request(final_url)
262-
req.add_header("Cache-control", "max-age=0")
264+
req = urllib2.Request(final_url, headers)
263265
response = urllib2.urlopen(req)
264266
if response.getcode() == 200:
265267
logging.debug("Got error code 200 from %s", cur_site)

0 commit comments

Comments
 (0)