kopia lustrzana https://github.com/snarfed/bridgy-fed
bug fix in webmention => activitypub target fetch error handling
fixes https://console.cloud.google.com/errors/CPyMpaulkMKWZApull/59/head
rodzic
27b643355f
commit
ef8b9b13cc
|
@ -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>', ''),
|
||||
|
|
|
@ -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:
|
||||
|
|
Ładowanie…
Reference in New Issue