From 17acc1b39c56b15e671a9db3fe0b14d2969a6173 Mon Sep 17 00:00:00 2001 From: jeroenlicht Date: Sun, 1 Sep 2019 17:18:44 +0200 Subject: [PATCH] Added User-Agent in headers for validate_image request to prevent server blocking Many websites are configured to block requests with a missing User-Agent Added 'User-Agent': 'Open Badges Validator Core' to the get headers on line 61 --- openbadges/verifier/tasks/images.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbadges/verifier/tasks/images.py b/openbadges/verifier/tasks/images.py index 9aa71fc..0771dde 100644 --- a/openbadges/verifier/tasks/images.py +++ b/openbadges/verifier/tasks/images.py @@ -58,7 +58,7 @@ def validate_image(state, task_meta, **options): else: try: result = session.get( - url, headers={'Accept': 'application/ld+json, application/json, image/png, image/svg+xml'} + url, headers={'User-Agent': 'Open Badges Validator Core', 'Accept': 'application/ld+json, application/json, image/png, image/svg+xml'} ) content_type = result.headers['content-type'] encoded_body = base64.b64encode(result.content)