web: add a fun header

Add a jokey powered by header for people who like to
look at that sort of thing :-)
This commit is contained in:
Damien Churchill 2011-11-04 00:50:11 +00:00
parent c405425993
commit c06d4dfea5
2 changed files with 12 additions and 0 deletions

View File

@ -273,6 +273,7 @@ class JSON(resource.Resource, component.Component):
def _send_response(self, request, response):
response = json.dumps(response)
request.setHeader("content-type", "application/x-json")
request.setHeader("x-powered-by", "Rum")
request.write(compress(response, request))
request.finish()

View File

@ -109,6 +109,7 @@ def rpath(*paths):
class GetText(resource.Resource):
def render(self, request):
request.setHeader("x-powered-by", "Rum")
request.setHeader("content-type", "text/javascript; encoding=utf-8")
template = Template(filename=rpath("gettext.js"))
return compress(template.render(), request)
@ -123,6 +124,7 @@ class Upload(resource.Resource):
Saves all uploaded files to the disk and returns a list of filenames,
each on a new line.
"""
request.setHeader("x-powered-by", "Rum")
# Block all other HTTP methods.
if request.method != "POST":
@ -161,6 +163,7 @@ class Render(resource.Resource):
return self
def render(self, request):
request.setHeader("x-powered-by", "Rum")
if not hasattr(request, "render_file"):
request.setResponseCode(http.INTERNAL_SERVER_ERROR)
return ""
@ -186,6 +189,7 @@ class Tracker(resource.Resource):
def on_got_icon(self, icon, request):
headers = {}
request.setHeader("x-powered-by", "Rum")
if icon:
request.setHeader("cache-control",
"public, must-revalidate, max-age=86400")
@ -214,6 +218,7 @@ class TorrentResource(resource.Resource):
def send_response(self, response, request):
request.setHeader("content-type", "text/plain")
request.setHeader("x-powered-by", "Rum")
request.write(compress(json.dumps(response), request))
request.finish()
@ -262,6 +267,7 @@ class Files(TorrentResource):
@secure
def render(self, request):
request.setHeader("x-powered-by", "Rum")
if not hasattr(request, 'torrent_id'):
request.setResponseCode(http.NOT_FOUND)
return '<h1>Not Found</h1>'
@ -285,6 +291,7 @@ class Peers(TorrentResource):
@secure
def render(self, request):
request.setHeader("x-powered-by", "Rum")
if not hasattr(request, 'torrent_id'):
request.setResponseCode(http.NOT_FOUND)
return '<h1>Not Found</h1>'
@ -300,6 +307,7 @@ class Flag(resource.Resource):
def render(self, request):
headers = {}
request.setHeader("x-powered-by", "Rum")
path = ("ui", "data", "pixmaps", "flags",
request.country.lower() + ".png")
filename = common.resource_filename("deluge", os.path.join(*path))
@ -342,6 +350,7 @@ class LookupResource(resource.Resource, component.Component):
def render(self, request):
log.debug("Requested path: '%s'", request.lookup_path)
request.setHeader("x-powered-by", "Rum")
path = os.path.dirname(request.lookup_path)
if path not in self.__paths:
@ -493,6 +502,7 @@ class ScriptResource(resource.Resource, component.Component):
def render(self, request):
log.debug("Requested path: '%s'", request.lookup_path)
request.setHeader("x-powered-by", "Rum")
for type in ("dev", "debug", "normal"):
scripts = self.__scripts[type]["scripts"]
@ -651,6 +661,7 @@ class TopLevel(resource.Resource):
template = Template(filename=rpath("index.html"))
request.setHeader("content-type", "text/html; charset=utf-8")
request.setHeader("x-powered-by", "Rum")
web_config = component.get("Web").get_config()
web_config["base"] = request.base