Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RSS feed not working due to Content Length Mismatch error

See original GitHub issue

I have just installed puput==0.9.1 as an app alongside the rest of my Django site, and I have noticed the RSS feed is not working.

The server appears to be serving the page OK: - - [09/Nov/2017 22:23:15] "GET /news/feed/ HTTP/1.1" 200 -
INFO _internal - - [09/Nov/2017 22:23:15] "GET /news/feed/ HTTP/1.1" 200 -

But the browser (Chromium) reports:

This page isn’t working

localhost unexpectedly closed the connection.

Note the content length mismatch error.

When I use the debugger to see the response to the syndication view I can see good data:

> /home/paul/dev/Syncables/.venv/lib/python3.5/site-packages/django/contrib/syndication/
-> feedgen = self.get_feed(obj, request)
(Pdb) pp request
<WSGIRequest: GET '/news/feed/'>
(Pdb) n
> /home/paul/dev/Syncables/.venv/lib/python3.5/site-packages/django/contrib/syndication/
-> response = HttpResponse(content_type=feedgen.content_type)
(Pdb) pp feedgen
<puput.feeds.BlogPageFeedGenerator object at 0x7f4c843dcc50>
(Pdb) pp feedgen.content_type
'application/rss+xml; charset=utf-8'
(Pdb) dir(feedgen)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_version', 'add_item', 'add_item_elements', 'add_root_elements', 'content_type', 'endChannelElement', 'feed', 'item_attributes', 'items', 'latest_post_date', 'mime_type', 'num_items', 'root_attributes', 'rss_attributes', 'write', 'writeString', 'write_items']
(Pdb) pp feedgen.items
[{'author_email': None,
  'author_link': None,
  'author_name': None,
  'categories': (),
  'comments': None,
  'description': '<p>Here is some more content</p>',
  'enclosures': [],
  'item_copyright': None,
  'link': 'https://localhost:8000/news/2017/11/09/my-2nd-post/',
  'pubdate': datetime.datetime(2017, 11, 9, 14, 3, tzinfo=<UTC>),
  'title': 'This is my 2nd post',
  'ttl': None,
  'unique_id': 'https://localhost:8000/news/2017/11/09/my-2nd-post/',
  'unique_id_is_permalink': None,
  'updateddate': None},
 {'author_email': None,
  'author_link': None,
  'author_name': None,
  'categories': (),
  'comments': None,
  'description': '<p>This is the body of the blog</p>',
  'enclosures': [],
  'item_copyright': None,
  'link': 'https://localhost:8000/news/2017/11/09/my-first-blog-post/',
  'pubdate': datetime.datetime(2017, 11, 9, 13, 29, tzinfo=<UTC>),
  'title': 'This is my first blog post',
  'ttl': None,
  'unique_id': 'https://localhost:8000/news/2017/11/09/my-first-blog-post/',
  'unique_id_is_permalink': None,
  'updateddate': None}]
(Pdb) print(response.content.decode('utf-8'))
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom=""><channel><title>News</title><link></link><description>All the news about Syncables products and services</description><atom:link rel="self" href=""></atom:link><language>en-gb</language><lastBuildDate>Thu, 09 Nov 2017 14:03:00 +0000</lastBuildDate><item><title>This is my 2nd post</title><link>https://localhost:8000/news/2017/11/09/my-2nd-post/</link><description>&lt;p&gt;Here is some more content&lt;/p&gt;</description><pubDate>Thu, 09 Nov 2017 14:03:00 +0000</pubDate><guid>https://localhost:8000/news/2017/11/09/my-2nd-post/</guid></item><item><title>This is my first blog post</title><link>https://localhost:8000/news/2017/11/09/my-first-blog-post/</link><description>&lt;p&gt;This is the body of the blog&lt;/p&gt;</description><pubDate>Thu, 09 Nov 2017 13:29:00 +0000</pubDate><guid>https://localhost:8000/news/2017/11/09/my-first-blog-post/</guid></item></channel></rss>

So this appears to be an issue with the way Django is handling the response successfully generated by Putput. This is using Django==1.11.4.

I checked the RSS XML output above in the RSS feed checker, and it validated OK with the exception of in the <link>. Don’t know where this comes from but it would appear to be a separate issue.

This feed is valid, but interoperability with the widest range of feed readers could be improved by implementing the following recommendations.
line 2, column 263: Self reference doesn't match document location [help]
... " href=""></atom:link><language>en-gb</lan ...

Any ideas?

Which part of Django is responsible for setting the correct content length for a response object?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

pjmcdermottcommented, Feb 21, 2018

@marctc Sorry, no. Switched away from Puput/Wagtail to Pinax due to the various issues I encountered.

On 15/02/18 16:49, Marc Tudurí wrote:

@pjmcdermott can you check if it works with the last version?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread

MiltonLncommented, Mar 11, 2018

If the issue still exists please re-open

Read more comments on GitHub >

github_iconTop Results From Across the Web

Content length mismatch - Google Groups
Content length mismatch. (1 error). The actual number of bytes received for a chunk or file does not match the expected value reported...
Read more >
Response Content-Length mismatch: too few bytes written
My ASP.NET Core app uses "out-of-box" external login authentication. What I want to implement - on facebook challenge I want to wrap redirect ......
Read more >
Err Content Length mismatch??? - DevCentral
So, when I put a VS behind a policy I get this error ERR_CONTENT_LENGTH_MISMATCH WHY? I have tried everything. Any help would be...
Read more >
Content-Length mismatch Installing Magento 2.3.6
This fixes any issues with local composer.json files too. No need to mess around with the composer.json file locally or globally.
Read more >
Problem with apache + ssl: length mismatch error and ...
It appears that your SSL handshake is dieing during cipher negotiation. I would check your SSLCipherSuite Apache configuration directive.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found