Log a warning when Content-Type is not correct
authorEtienne Millon <me@emillon.org>
Sun, 28 Sep 2014 19:56:41 +0000 (21:56 +0200)
committerEtienne Millon <me@emillon.org>
Sun, 28 Sep 2014 19:56:41 +0000 (21:56 +0200)
When a feed is served with a wrong Content-Type, log a warning and not an error.
This prevents a "processing error" message from being displayed at the default
log level, which is confusing for a innocuous "error" like this.

See https://bugs.debian.org/760963.

Signed-off-by: Etienne Millon <me@emillon.org>
rss2email/feed.py

index 55979a3689ff72713cd09e77112172a998b11e11..ec5c4f683741fe3b8d4c10c3ebea15dfbab941e2 100644 (file)
@@ -423,6 +423,9 @@ class Feed (object):
             _LOG.warning(
                 'incorrectly declared encoding: {}: {}'.format(exc, self))
             warned = True
+        elif (parsed.bozo and isinstance(exc, _feedparser.NonXMLContentType)):
+            _LOG.warning('non XML Content-Type: {}: {}'.format(exc, self))
+            warned = True
         elif parsed.bozo or exc:
             if exc is None:
                 exc = "can't process"