From 867be4d24932829f2ecd9223d3d69e3bd43befd0 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 27 Feb 2020 20:33:49 +0000 Subject: [PATCH] rss mime type --- daemon.py | 102 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 52 insertions(+), 50 deletions(-) diff --git a/daemon.py b/daemon.py index e0343d80..730a9acc 100644 --- a/daemon.py +++ b/daemon.py @@ -1025,7 +1025,7 @@ class PubServer(BaseHTTPRequestHandler): maxPostsInRSSFeed,1) if msg!=None: msg=msg.encode() - self._set_headers('application/rss+xml',len(msg),cookie) + self._set_headers('text/xml',len(msg),cookie) self._write(msg) return self._404() @@ -1036,61 +1036,63 @@ class PubServer(BaseHTTPRequestHandler): self.path=='/blog/' or \ self.path=='/blogs' or \ self.path=='/blogs/'): - if not self.server.session: - self.server.session= \ - createSession(self.server.useTor) - msg=htmlBlogView(authorized, \ - self.server.session, \ - self.server.baseDir, \ - self.server.httpPrefix, \ - self.server.translate, \ - self.server.domain,self.server.port, \ - maxPostsInBlogsFeed) - if msg!=None: - msg=msg.encode() - self._set_headers('text/html',len(msg),cookie) - self._write(msg) + if '/rss.xml' not in self.path: + if not self.server.session: + self.server.session= \ + createSession(self.server.useTor) + msg=htmlBlogView(authorized, \ + self.server.session, \ + self.server.baseDir, \ + self.server.httpPrefix, \ + self.server.translate, \ + self.server.domain,self.server.port, \ + maxPostsInBlogsFeed) + if msg!=None: + msg=msg.encode() + self._set_headers('text/html',len(msg),cookie) + self._write(msg) + return + self._404() return - self._404() - return # show a particular page of blog entries # for a particular account if htmlGET and self.path.startswith('/blog/'): - pageNumber=1 - nickname=self.path.split('/blog/')[1] - if '/' in nickname: - nickname=nickname.split('/')[0] - if '?' in nickname: - nickname=nickname.split('?')[0] - if '?page=' in self.path: - pageNumberStr=self.path.split('?page=')[1] - if '?' in pageNumberStr: - pageNumberStr=pageNumberStr.split('?')[0] - if pageNumberStr.isdigit(): - pageNumber=int(pageNumberStr) - if pageNumber<1: - pageNumber=1 - elif pageNumber>10: - pageNumber=10 - if not self.server.session: - self.server.session= \ - createSession(self.server.useTor) - msg=htmlBlogPage(authorized, \ - self.server.session, \ - self.server.baseDir, \ - self.server.httpPrefix, \ - self.server.translate, \ - nickname, \ - self.server.domain,self.server.port, \ - maxPostsInBlogsFeed,pageNumber) - if msg!=None: - msg=msg.encode() - self._set_headers('text/html',len(msg),cookie) - self._write(msg) + if '/rss.xml' not in self.path: + pageNumber=1 + nickname=self.path.split('/blog/')[1] + if '/' in nickname: + nickname=nickname.split('/')[0] + if '?' in nickname: + nickname=nickname.split('?')[0] + if '?page=' in self.path: + pageNumberStr=self.path.split('?page=')[1] + if '?' in pageNumberStr: + pageNumberStr=pageNumberStr.split('?')[0] + if pageNumberStr.isdigit(): + pageNumber=int(pageNumberStr) + if pageNumber<1: + pageNumber=1 + elif pageNumber>10: + pageNumber=10 + if not self.server.session: + self.server.session= \ + createSession(self.server.useTor) + msg=htmlBlogPage(authorized, \ + self.server.session, \ + self.server.baseDir, \ + self.server.httpPrefix, \ + self.server.translate, \ + nickname, \ + self.server.domain,self.server.port, \ + maxPostsInBlogsFeed,pageNumber) + if msg!=None: + msg=msg.encode() + self._set_headers('text/html',len(msg),cookie) + self._write(msg) + return + self._404() return - self._404() - return if htmlGET and '/users/' in self.path: # show the person options screen with view/follow/block/report