Skip to content

Commit 3ada264

Browse files
author
Richard Jones
committed
implement the HTTP HEAD command [SF#992544]
1 parent 115122a commit 3ada264

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Fixed:
3131
- fixed DateHTMLProperty for invalid date entry (sf bug 986538)
3232
- fixed external password source example (sf bug 986601)
3333
- document the STATIC_FILES config var
34+
- implement the HTTP HEAD command (sf bug 992544)
3435

3536

3637
2004-06-24 0.7.5

roundup/cgi/actions.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#$Id: actions.py,v 1.34 2004-07-13 09:41:15 a1s Exp $
1+
#$Id: actions.py,v 1.35 2004-07-20 02:07:58 richard Exp $
22

33
import re, cgi, StringIO, urllib, Cookie, time, random
44

@@ -882,7 +882,13 @@ def handle(self):
882882
h['Content-Type'] = 'text/csv'
883883
# some browsers will honor the filename here...
884884
h['Content-Disposition'] = 'inline; filename=query.csv'
885+
885886
self.client.header()
887+
888+
if self.client.env['REQUEST_METHOD'] == 'HEAD':
889+
# all done, return a dummy string
890+
return 'dummy'
891+
886892
writer = rcsv.writer(self.client.request.wfile)
887893
writer.writerow(columns)
888894

roundup/cgi/client.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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 $
22

33
"""WWW request handler (also used in the stand-alone server).
44
"""
@@ -675,7 +675,8 @@ def handle_action(self):
675675
def write(self, content):
676676
if not self.headers_done:
677677
self.header()
678-
self.request.wfile.write(content)
678+
if self.env['REQUEST_METHOD'] != 'HEAD':
679+
self.request.wfile.write(content)
679680

680681
def write_html(self, content):
681682
if not self.headers_done:
@@ -694,10 +695,17 @@ def write_html(self, content):
694695
'roundup_charset=%s; expires=%s; Path=%s;' % (
695696
self.charset, expire, self.cookie_path)
696697
self.header()
698+
699+
if self.env['REQUEST_METHOD'] == 'HEAD':
700+
# client doesn't care about content
701+
return
702+
697703
if self.charset != self.STORAGE_CHARSET:
698704
# recode output
699705
content = content.decode(self.STORAGE_CHARSET, 'replace')
700706
content = content.encode(self.charset, 'xmlcharrefreplace')
707+
708+
# and write
701709
self.request.wfile.write(content)
702710

703711
def setHeader(self, header, value):

roundup/scripts/roundup_server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
"""Command-line script that runs a server over roundup.cgi.client.
1919
20-
$Id: roundup_server.py,v 1.55 2004-07-13 10:24:19 a1s Exp $
20+
$Id: roundup_server.py,v 1.56 2004-07-20 02:07:58 richard Exp $
2121
"""
2222
__docformat__ = 'restructuredtext'
2323

@@ -118,7 +118,7 @@ def run_cgi(self):
118118
self.wfile.write("</pre>\n")
119119
sys.stdin = save_stdin
120120

121-
do_GET = do_POST = run_cgi
121+
do_GET = do_POST = do_HEAD = run_cgi
122122

123123
def index(self):
124124
''' Print up an index of the available trackers

0 commit comments

Comments
 (0)