comparison roundup/cgi/client.py @ 2592:5a8d9465827e

implement the HTTP HEAD command [SF#992544]
author Richard Jones <richard@users.sourceforge.net>
date Tue, 20 Jul 2004 02:07:58 +0000
parents 89c5e8564dad
children 18e86941c950
comparison
equal deleted inserted replaced
2591:5f52d113de0c 2592:5a8d9465827e
1 # $Id: client.py,v 1.183 2004-07-13 10:19:13 a1s Exp $ 1 # $Id: client.py,v 1.184 2004-07-20 02:07:58 richard Exp $
2 2
3 """WWW request handler (also used in the stand-alone server). 3 """WWW request handler (also used in the stand-alone server).
4 """ 4 """
5 __docformat__ = 'restructuredtext' 5 __docformat__ = 'restructuredtext'
6 6
673 self.error_message.append(str(err)) 673 self.error_message.append(str(err))
674 674
675 def write(self, content): 675 def write(self, content):
676 if not self.headers_done: 676 if not self.headers_done:
677 self.header() 677 self.header()
678 self.request.wfile.write(content) 678 if self.env['REQUEST_METHOD'] != 'HEAD':
679 self.request.wfile.write(content)
679 680
680 def write_html(self, content): 681 def write_html(self, content):
681 if not self.headers_done: 682 if not self.headers_done:
682 # at this point, we are sure about Content-Type 683 # at this point, we are sure about Content-Type
683 self.additional_headers['Content-Type'] = \ 684 self.additional_headers['Content-Type'] = \
692 expire = Cookie._getdate(86400*365) 693 expire = Cookie._getdate(86400*365)
693 self.additional_headers['Set-Cookie'] = \ 694 self.additional_headers['Set-Cookie'] = \
694 'roundup_charset=%s; expires=%s; Path=%s;' % ( 695 'roundup_charset=%s; expires=%s; Path=%s;' % (
695 self.charset, expire, self.cookie_path) 696 self.charset, expire, self.cookie_path)
696 self.header() 697 self.header()
698
699 if self.env['REQUEST_METHOD'] == 'HEAD':
700 # client doesn't care about content
701 return
702
697 if self.charset != self.STORAGE_CHARSET: 703 if self.charset != self.STORAGE_CHARSET:
698 # recode output 704 # recode output
699 content = content.decode(self.STORAGE_CHARSET, 'replace') 705 content = content.decode(self.STORAGE_CHARSET, 'replace')
700 content = content.encode(self.charset, 'xmlcharrefreplace') 706 content = content.encode(self.charset, 'xmlcharrefreplace')
707
708 # and write
701 self.request.wfile.write(content) 709 self.request.wfile.write(content)
702 710
703 def setHeader(self, header, value): 711 def setHeader(self, header, value):
704 '''Override a header to be returned to the user's browser. 712 '''Override a header to be returned to the user's browser.
705 ''' 713 '''

Roundup Issue Tracker: http://roundup-tracker.org/