bug fix in webmention => activitypub target fetch error handling

fixes https://console.cloud.google.com/errors/CPyMpaulkMKWZA
pull/59/head
Ryan Barrett 2019-08-13 07:23:26 -07:00
rodzic 27b643355f
commit ef8b9b13cc
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 13 dodań i 3 usunięć

Wyświetl plik

@ -335,6 +335,16 @@ class WebmentionTest(testutil.TestCase):
body=urllib.urlencode({'source': 'http://a/post'}))
self.assertEquals(400, got.status_int)
def test_target_fetch_fails(self, mock_get, mock_post):
mock_get.side_effect = (
requests_response(self.reply_html.replace('http://orig/post', 'bad'),
content_type=CONTENT_TYPE_HTML),
requests.Timeout('foo bar'))
got = app.get_response('/webmention', method='POST',
body=urllib.urlencode({'source': 'http://a/post'}))
self.assertEquals(502, got.status_int)
def test_no_backlink(self, mock_get, mock_post):
mock_get.return_value = requests_response(
self.reply_html.replace('<a href="http://localhost/"></a>', ''),

Wyświetl plik

@ -170,9 +170,9 @@ class WebmentionHandler(webapp2.RequestHandler):
try:
self.target_resp = common.get_as2(target)
except (requests.HTTPError, exc.HTTPBadGateway) as e:
self.target_resp = e.response
if (e.response.status_code // 100 == 2 and
common.content_type(e.response).startswith('text/html')):
self.target_resp = getattr(e, 'response', None)
if (self.target_resp and self.target_resp.status_code // 100 == 2 and
common.content_type(self.target_resp).startswith('text/html')):
# TODO: pass e.response to try_salmon()'s target_resp
return False # make post() try Salmon
else: