diff mercurial/hgweb/webcommands.py @ 5993:948a41e77902

hgweb: explicit response status
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Fri, 01 Feb 2008 10:31:13 +0100
parents 1cd1582ef25f
children fe8dbbe9520d
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py	Fri Feb 01 10:31:09 2008 +0100
+++ b/mercurial/hgweb/webcommands.py	Fri Feb 01 10:31:13 2008 +0100
@@ -7,7 +7,7 @@
 
 import os, mimetypes
 from mercurial import revlog, util, hg
-from common import staticfile, ErrorResponse
+from common import staticfile, ErrorResponse, HTTP_OK, HTTP_NOT_FOUND
 
 # __all__ is populated with the allowed commands. Be sure to add to it if
 # you're adding a new command, or the new command won't work.
@@ -27,12 +27,16 @@
 def rawfile(web, req, tmpl):
     path = web.cleanpath(req.form.get('file', [''])[0])
     if not path:
-        return web.manifest(tmpl, web.changectx(req), path)
+        content = web.manifest(tmpl, web.changectx(req), path)
+        req.respond(HTTP_OK, web.ctype)
+        return content
 
     try:
         fctx = web.filectx(req)
     except revlog.LookupError:
-        return web.manifest(tmpl, web.changectx(req), path)
+        content = web.manifest(tmpl, web.changectx(req), path)
+        req.respond(HTTP_OK, web.ctype)
+        return content
 
     path = fctx.path()
     text = fctx.data()
@@ -40,7 +44,7 @@
     if mt is None or util.binary(text):
         mt = mt or 'application/octet-stream'
 
-    req.httphdr(mt, path, len(text))
+    req.respond(HTTP_OK, mt, path, len(text))
     return [text]
 
 def file(web, req, tmpl):
@@ -104,8 +108,7 @@
         web.configbool("web", "allow" + type_, False))):
         web.archive(tmpl, req, req.form['node'][0], type_)
         return []
-
-    raise ErrorResponse(400, 'Unsupported archive type: %s' % type_)
+    raise ErrorResponse(HTTP_NOT_FOUND, 'Unsupported archive type: %s' % type_)
 
 def static(web, req, tmpl):
     fname = req.form['file'][0]