From 3a4e6db04d02e754be9587bc0dd92f1d497d81b7 Mon Sep 17 00:00:00 2001 From: Jeremy Carbaugh Date: Fri, 1 Nov 2013 16:37:27 -0400 Subject: [PATCH] Allow legacy mimetypes in JRD response --- webfinger.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/webfinger.py b/webfinger.py index 348b9c1..800c27a 100644 --- a/webfinger.py +++ b/webfinger.py @@ -16,6 +16,7 @@ RELS = { } WEBFINGER_TYPE = 'application/jrd+json' +LEGACY_WEBFINGER_TYPES = ['application/json'] UNOFFICIAL_ENDPOINTS = { 'facebook.com': 'facebook-webfinger.appspot.com', @@ -94,12 +95,12 @@ class WebFingerClient(object): logging.debug('fetching JRD from %s' % resp.url) content = resp.content - content_type = resp.headers.get('Content-Type') + content_type = resp.headers.get('Content-Type', '').split(';', 1)[0].strip() logging.debug('response content type: %s' % content_type) - # if content_type != WEBFINGER_TYPE: - # raise WebFingerException('Invalid response type from server') + if content_type != WEBFINGER_TYPE and content_type not in LEGACY_WEBFINGER_TYPES: + raise WebFingerException('Invalid response type from server') if raw: return content