# HG changeset patch # User Dirkjan Ochtman # Date 1201094905 -3600 # Node ID c301f15c965ac2d36259dcbfae3a981ccf007150 # Parent e160f231281594dd51b897861146bf2e111775ef send conservatively capitalized HTTP headers diff -r e160f2312815 -r c301f15c965a mercurial/byterange.py --- 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) diff -r e160f2312815 -r c301f15c965a mercurial/hgweb/common.py --- 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') diff -r e160f2312815 -r c301f15c965a mercurial/hgweb/hgweb_mod.py --- 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) diff -r e160f2312815 -r c301f15c965a mercurial/hgweb/request.py --- 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): diff -r e160f2312815 -r c301f15c965a mercurial/httprepo.py --- 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()) diff -r e160f2312815 -r c301f15c965a tests/test-hgweb-no-request-uri.out --- 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')] @@ -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 diff -r e160f2312815 -r c301f15c965a tests/test-non-interactive-wsgi.out --- 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