#113 add cache-control+content-length for /pixamps

This commit is contained in:
Martijn Voncken 2008-03-24 08:59:46 +00:00
parent 8eda411a86
commit 7121abc572
3 changed files with 26 additions and 4 deletions

View File

@ -50,7 +50,8 @@ class static_handler:
web.header("Content-type", ctype)
fs = os.fstat(f.fileno())
web.header("Content-Length", str(fs[6]))
web.lastmodified(datetime.datetime.fromtimestamp(fs.st_mtime))
web.header("Cache-Control" , "public, must-revalidate, max-age=86400")
#web.lastmodified(datetime.datetime.fromtimestamp(fs.st_mtime))
print f.read()
def translate_path(self, path):

View File

@ -196,6 +196,22 @@ class torrent_info_inner:
#next 6 classes: a pattern is emerging here.
#todo: DRY (in less lines of code)
#deco.deluge_command, or a subclass?
"""
def torrents_command(command):
class torrents_command_inner:
@deco.check_session
@deco.torrent_ids
def POST(self, torrent_ids):
proxy.getattr(command).(torrent_ids)
do_redirect()
torrent_start = torrents_command("resume_torrent")
torrent_stop = torrents_command("pause_torrent")
torrent_reannounce = torrents_command("force_reannounce")
torrent_recheck = torrents_command("force_recheck")
torrent_queue_down = torrents_command("queue_down")
torrent_queue_up = torrents_command("queue_up")
"""
class torrent_start:
@deco.check_session
@deco.torrent_ids
@ -448,10 +464,15 @@ class pixmaps:
if not os.path.exists(get_pixmap(name)):
name = 'dht16.png'
web.header("Content-Type", "image/png")
f = open(get_pixmap(name) ,'rb')
print f.read()
fs = os.fstat(f.fileno())
content = f.read()
f.close()
web.header("Content-Type", "image/png")
web.header("Content-Length", str(fs[6]))
web.header("Cache-Control" , "public, must-revalidate, max-age=86400")
print content
#/pages

View File

@ -193,7 +193,7 @@ def get_enhanced_torrent_list(torrent_ids):
def get_newforms_data(form_class):
"""
glue for using web.py and newforms.
returns a storified dict with name/value of the post-data.
returns a dict with name/value of the post-data.
"""
import lib.newforms_plus as forms
fields = form_class.base_fields.keys()