changeset 5930:c301f15c965a

send conservatively capitalized HTTP headers
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Wed, 23 Jan 2008 14:28:25 +0100
parents e160f2312815
children 6482d34974ac
files mercurial/byterange.py mercurial/hgweb/common.py mercurial/hgweb/hgweb_mod.py mercurial/hgweb/request.py mercurial/httprepo.py tests/test-hgweb-no-request-uri.out tests/test-non-interactive-wsgi.out
diffstat 7 files changed, 24 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/byterange.py	Wed Jan 16 19:14:54 2008 +0330
+++ b/mercurial/byterange.py	Wed Jan 23 14:28:25 2008 +0100
@@ -233,7 +233,7 @@
             size = (lb - fb)
             fo = RangeableFileObject(fo, (fb, lb))
         headers = mimetools.Message(StringIO(
-            'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' %
+            'Content-Type: %s\nContent-Length: %d\nLast-Modified: %s\n' %
             (mtype or 'text/plain', size, modified)))
         return urllib.addinfourl(fo, headers, 'file:'+file)
 
--- a/mercurial/hgweb/common.py	Wed Jan 16 19:14:54 2008 +0330
+++ b/mercurial/hgweb/common.py	Wed Jan 23 14:28:25 2008 +0100
@@ -36,11 +36,11 @@
         return os.stat(store_path).st_mtime
 
 def staticfile(directory, fname, req):
-    """return a file inside directory with guessed content-type header
+    """return a file inside directory with guessed Content-Type header
 
     fname always uses '/' as directory separator and isn't allowed to
     contain unusual path components.
-    Content-type is guessed using the mimetypes module.
+    Content-Type is guessed using the mimetypes module.
     Return an empty string if fname is illegal or file not found.
 
     """
@@ -54,8 +54,10 @@
     try:
         os.stat(path)
         ct = mimetypes.guess_type(path)[0] or "text/plain"
-        req.header([('Content-type', ct),
-                    ('Content-length', str(os.path.getsize(path)))])
+        req.header([
+            ('Content-Type', ct),
+            ('Content-Length', str(os.path.getsize(path)))
+        ])
         return file(path, 'rb').read()
     except TypeError:
         raise ErrorResponse(500, 'illegal file name')
--- a/mercurial/hgweb/hgweb_mod.py	Wed Jan 16 19:14:54 2008 +0330
+++ b/mercurial/hgweb/hgweb_mod.py	Wed Jan 23 14:28:25 2008 +0100
@@ -844,11 +844,13 @@
             arch_version = short(cnode)
         name = "%s-%s" % (reponame, arch_version)
         mimetype, artype, extension, encoding = self.archive_specs[type_]
-        headers = [('Content-type', mimetype),
-                   ('Content-disposition', 'attachment; filename=%s%s' %
-                    (name, extension))]
+        headers = [
+            ('Content-Type', mimetype),
+            ('Content-Disposition', 'attachment; filename=%s%s' %
+                (name, extension))
+        ]
         if encoding:
-            headers.append(('Content-encoding', encoding))
+            headers.append(('Content-Encoding', encoding))
         req.header(headers)
         archival.archive(self.repo, req, cnode, artype, prefix=name)
 
--- a/mercurial/hgweb/request.py	Wed Jan 16 19:14:54 2008 +0330
+++ b/mercurial/hgweb/request.py	Wed Jan 23 14:28:25 2008 +0100
@@ -80,17 +80,17 @@
     def close(self):
         return None
 
-    def header(self, headers=[('Content-type','text/html')]):
+    def header(self, headers=[('Content-Type','text/html')]):
         self.headers.extend(headers)
 
     def httphdr(self, type, filename=None, length=0, headers={}):
         headers = headers.items()
-        headers.append(('Content-type', type))
+        headers.append(('Content-Type', type))
         if filename:
-            headers.append(('Content-disposition', 'inline; filename=%s' %
+            headers.append(('Content-Disposition', 'inline; filename=%s' %
                             filename))
         if length:
-            headers.append(('Content-length', str(length)))
+            headers.append(('Content-Length', str(length)))
         self.header(headers)
 
 def wsgiapplication(app_maker):
--- a/mercurial/httprepo.py	Wed Jan 16 19:14:54 2008 +0330
+++ b/mercurial/httprepo.py	Wed Jan 23 14:28:25 2008 +0100
@@ -343,7 +343,7 @@
                 version = proto.split('-', 1)[1]
                 version_info = tuple([int(n) for n in version.split('.')])
             except ValueError:
-                raise repo.RepoError(_("'%s' sent a broken Content-type "
+                raise repo.RepoError(_("'%s' sent a broken Content-Type "
                                      "header (%s)") % (self._url, proto))
             if version_info > (0, 1):
                 raise repo.RepoError(_("'%s' uses newer protocol %s") %
@@ -428,7 +428,7 @@
             try:
                 rfp = self.do_cmd(
                     'unbundle', data=fp,
-                    headers={'content-type': 'application/octet-stream'},
+                    headers={'Content-Type': 'application/octet-stream'},
                     heads=' '.join(map(hex, heads)))
                 try:
                     ret = int(rfp.readline())
--- a/tests/test-hgweb-no-request-uri.out	Wed Jan 16 19:14:54 2008 +0330
+++ b/tests/test-hgweb-no-request-uri.out	Wed Jan 23 14:28:25 2008 +0100
@@ -7,7 +7,7 @@
 ---- HEADERS
 200 Script output follows
 ---- DATA
-[('Content-type', 'application/atom+xml; charset=ascii')]
+[('Content-Type', 'application/atom+xml; charset=ascii')]
 <?xml version="1.0" encoding="ascii"?>
 <feed xmlns="http://www.w3.org/2005/Atom">
  <!-- Changelog -->
@@ -41,7 +41,7 @@
 ---- HEADERS
 200 Script output follows
 ---- DATA
-[('Content-type', 'text/plain; charset=ascii')]
+[('Content-Type', 'text/plain; charset=ascii')]
 
 -rw-r--r-- 4 bar
 
@@ -52,7 +52,7 @@
 ---- HEADERS
 200 Script output follows
 ---- DATA
-[('Content-type', 'text/plain; charset=ascii')]
+[('Content-Type', 'text/plain; charset=ascii')]
 
 /repo/
 
@@ -62,7 +62,7 @@
 ---- HEADERS
 200 Script output follows
 ---- DATA
-[('Content-type', 'text/plain; charset=ascii')]
+[('Content-Type', 'text/plain; charset=ascii')]
 
 -rw-r--r-- 4 bar
 
--- a/tests/test-non-interactive-wsgi.out	Wed Jan 16 19:14:54 2008 +0330
+++ b/tests/test-non-interactive-wsgi.out	Wed Jan 23 14:28:25 2008 +0100
@@ -7,6 +7,6 @@
 ---- HEADERS
 200 Script output follows
 ---- DATA
-[('Content-type', 'text/html; charset=ascii')]
+[('Content-Type', 'text/html; charset=ascii')]
 ---- ERRORS