kopia lustrzana https://github.com/snarfed/bridgy-fed
web.poll_feed_task: handle missing Content-Type header
fixes https://console.cloud.google.com/errors/detail/CKiskJSXi5z9gwE;time=P30D?project=bridgy-federatedpull/785/head
rodzic
34848b748e
commit
ab4427c182
|
@ -1946,7 +1946,7 @@ class WebTest(TestCase):
|
|||
self.assertEqual(504, got.status_code)
|
||||
self.assertIsNone(self.user.key.get().last_polled_feed)
|
||||
|
||||
def test_poll_feed_wrong_content_type(self, mock_get, _):
|
||||
def test_poll_feed_wrong_content_types(self, mock_get, _):
|
||||
common.RUN_TASKS_INLINE = False
|
||||
self.user.obj.mf2 = {
|
||||
**ACTOR_MF2,
|
||||
|
@ -1956,12 +1956,12 @@ class WebTest(TestCase):
|
|||
}
|
||||
self.user.obj.put()
|
||||
|
||||
mock_get.return_value = requests_response(
|
||||
'nope', headers={'Content-Type': 'text/plain'})
|
||||
|
||||
got = self.post('/queue/poll-feed', data={'domain': 'user.com'})
|
||||
self.assertEqual(200, got.status_code)
|
||||
self.assertIsNone(self.user.key.get().last_polled_feed)
|
||||
for content_type in None, 'text/plain':
|
||||
mock_get.return_value = requests_response(
|
||||
'nope', headers={'Content-Type': content_type})
|
||||
got = self.post('/queue/poll-feed', data={'domain': 'user.com'})
|
||||
self.assertEqual(200, got.status_code)
|
||||
self.assertIsNone(self.user.key.get().last_polled_feed)
|
||||
|
||||
@patch('oauth_dropins.webutil.appengine_config.tasks_client.create_task')
|
||||
def test_poll_feed_last_webmention_in_noop(self, mock_create_task, mock_get, _):
|
||||
|
|
3
web.py
3
web.py
|
@ -613,6 +613,7 @@ def webmention_interactive():
|
|||
|
||||
|
||||
@app.post(f'/queue/poll-feed')
|
||||
@cloud_tasks_only
|
||||
def poll_feed_task():
|
||||
"""Fetches a :class:`Web` site's feed and delivers new/updated posts.
|
||||
|
||||
|
@ -639,7 +640,7 @@ def poll_feed_task():
|
|||
|
||||
# fetch feed
|
||||
resp = util.requests_get(url)
|
||||
content_type = resp.headers.get('Content-Type')
|
||||
content_type = resp.headers.get('Content-Type') or ''
|
||||
type = FEED_TYPES.get(content_type.split(';')[0])
|
||||
if type == 'atom' or (type == 'xml' and rel_type == 'atom'):
|
||||
activities = atom.atom_to_activities(resp.text)
|
||||
|
|
Ładowanie…
Reference in New Issue