Skip to content

Commit

Permalink
return NO_ENDPOINT for webmention target URLs that aren't HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
snarfed committed Sep 12, 2014
1 parent 52eda77 commit 5d2e75a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion webmentiontools/send.py
Expand Up @@ -30,12 +30,18 @@ def _discoverEndpoint(self):
r = requests.get(self.target_url, verify=False, **self.requests_kwargs)
if r.status_code != 200:
self.error = {
'code':'BAD_TARGET_URL',
'code': 'BAD_TARGET_URL',
'error_description': 'Unable to get target URL.',
'request': 'GET %s' % self.target_url,
'http_status': r.status_code,
}
return
elif r.headers.get('content-type') != 'text/html':
self.error = {
'code': 'NO_ENDPOINT',
'error_description': 'Unable to discover webmention endpoint.'
}
return
self.html = r.text

# look in the headers
Expand Down

0 comments on commit 5d2e75a

Please sign in to comment.