Show More
@@ -233,7 +233,7 b' class FileRangeHandler(urllib2.FileHandl' | |||||
233 | size = (lb - fb) |
|
233 | size = (lb - fb) | |
234 | fo = RangeableFileObject(fo, (fb, lb)) |
|
234 | fo = RangeableFileObject(fo, (fb, lb)) | |
235 | headers = mimetools.Message(StringIO( |
|
235 | headers = mimetools.Message(StringIO( | |
236 |
'Content-Type: %s\nContent-Length: %d\nLast- |
|
236 | 'Content-Type: %s\nContent-Length: %d\nLast-Modified: %s\n' % | |
237 | (mtype or 'text/plain', size, modified))) |
|
237 | (mtype or 'text/plain', size, modified))) | |
238 | return urllib.addinfourl(fo, headers, 'file:'+file) |
|
238 | return urllib.addinfourl(fo, headers, 'file:'+file) | |
239 |
|
239 |
@@ -36,11 +36,11 b' def get_mtime(repo_path):' | |||||
36 | return os.stat(store_path).st_mtime |
|
36 | return os.stat(store_path).st_mtime | |
37 |
|
37 | |||
38 | def staticfile(directory, fname, req): |
|
38 | def staticfile(directory, fname, req): | |
39 |
"""return a file inside directory with guessed |
|
39 | """return a file inside directory with guessed Content-Type header | |
40 |
|
40 | |||
41 | fname always uses '/' as directory separator and isn't allowed to |
|
41 | fname always uses '/' as directory separator and isn't allowed to | |
42 | contain unusual path components. |
|
42 | contain unusual path components. | |
43 |
Content- |
|
43 | Content-Type is guessed using the mimetypes module. | |
44 | Return an empty string if fname is illegal or file not found. |
|
44 | Return an empty string if fname is illegal or file not found. | |
45 |
|
45 | |||
46 | """ |
|
46 | """ | |
@@ -54,8 +54,10 b' def staticfile(directory, fname, req):' | |||||
54 | try: |
|
54 | try: | |
55 | os.stat(path) |
|
55 | os.stat(path) | |
56 | ct = mimetypes.guess_type(path)[0] or "text/plain" |
|
56 | ct = mimetypes.guess_type(path)[0] or "text/plain" | |
57 |
req.header([ |
|
57 | req.header([ | |
58 | ('Content-length', str(os.path.getsize(path)))]) |
|
58 | ('Content-Type', ct), | |
|
59 | ('Content-Length', str(os.path.getsize(path))) | |||
|
60 | ]) | |||
59 | return file(path, 'rb').read() |
|
61 | return file(path, 'rb').read() | |
60 | except TypeError: |
|
62 | except TypeError: | |
61 | raise ErrorResponse(500, 'illegal file name') |
|
63 | raise ErrorResponse(500, 'illegal file name') |
@@ -844,11 +844,13 b' class hgweb(object):' | |||||
844 | arch_version = short(cnode) |
|
844 | arch_version = short(cnode) | |
845 | name = "%s-%s" % (reponame, arch_version) |
|
845 | name = "%s-%s" % (reponame, arch_version) | |
846 | mimetype, artype, extension, encoding = self.archive_specs[type_] |
|
846 | mimetype, artype, extension, encoding = self.archive_specs[type_] | |
847 | headers = [('Content-type', mimetype), |
|
847 | headers = [ | |
848 | ('Content-disposition', 'attachment; filename=%s%s' % |
|
848 | ('Content-Type', mimetype), | |
849 | (name, extension))] |
|
849 | ('Content-Disposition', 'attachment; filename=%s%s' % | |
|
850 | (name, extension)) | |||
|
851 | ] | |||
850 | if encoding: |
|
852 | if encoding: | |
851 |
headers.append(('Content- |
|
853 | headers.append(('Content-Encoding', encoding)) | |
852 | req.header(headers) |
|
854 | req.header(headers) | |
853 | archival.archive(self.repo, req, cnode, artype, prefix=name) |
|
855 | archival.archive(self.repo, req, cnode, artype, prefix=name) | |
854 |
|
856 |
@@ -80,17 +80,17 b' class wsgirequest(object):' | |||||
80 | def close(self): |
|
80 | def close(self): | |
81 | return None |
|
81 | return None | |
82 |
|
82 | |||
83 |
def header(self, headers=[('Content- |
|
83 | def header(self, headers=[('Content-Type','text/html')]): | |
84 | self.headers.extend(headers) |
|
84 | self.headers.extend(headers) | |
85 |
|
85 | |||
86 | def httphdr(self, type, filename=None, length=0, headers={}): |
|
86 | def httphdr(self, type, filename=None, length=0, headers={}): | |
87 | headers = headers.items() |
|
87 | headers = headers.items() | |
88 |
headers.append(('Content- |
|
88 | headers.append(('Content-Type', type)) | |
89 | if filename: |
|
89 | if filename: | |
90 |
headers.append(('Content- |
|
90 | headers.append(('Content-Disposition', 'inline; filename=%s' % | |
91 | filename)) |
|
91 | filename)) | |
92 | if length: |
|
92 | if length: | |
93 |
headers.append(('Content- |
|
93 | headers.append(('Content-Length', str(length))) | |
94 | self.header(headers) |
|
94 | self.header(headers) | |
95 |
|
95 | |||
96 | def wsgiapplication(app_maker): |
|
96 | def wsgiapplication(app_maker): |
@@ -343,7 +343,7 b' class httprepository(remoterepository):' | |||||
343 | version = proto.split('-', 1)[1] |
|
343 | version = proto.split('-', 1)[1] | |
344 | version_info = tuple([int(n) for n in version.split('.')]) |
|
344 | version_info = tuple([int(n) for n in version.split('.')]) | |
345 | except ValueError: |
|
345 | except ValueError: | |
346 |
raise repo.RepoError(_("'%s' sent a broken Content- |
|
346 | raise repo.RepoError(_("'%s' sent a broken Content-Type " | |
347 | "header (%s)") % (self._url, proto)) |
|
347 | "header (%s)") % (self._url, proto)) | |
348 | if version_info > (0, 1): |
|
348 | if version_info > (0, 1): | |
349 | raise repo.RepoError(_("'%s' uses newer protocol %s") % |
|
349 | raise repo.RepoError(_("'%s' uses newer protocol %s") % | |
@@ -428,7 +428,7 b' class httprepository(remoterepository):' | |||||
428 | try: |
|
428 | try: | |
429 | rfp = self.do_cmd( |
|
429 | rfp = self.do_cmd( | |
430 | 'unbundle', data=fp, |
|
430 | 'unbundle', data=fp, | |
431 |
headers={' |
|
431 | headers={'Content-Type': 'application/octet-stream'}, | |
432 | heads=' '.join(map(hex, heads))) |
|
432 | heads=' '.join(map(hex, heads))) | |
433 | try: |
|
433 | try: | |
434 | ret = int(rfp.readline()) |
|
434 | ret = int(rfp.readline()) |
@@ -7,7 +7,7 b' summary: test' | |||||
7 | ---- HEADERS |
|
7 | ---- HEADERS | |
8 | 200 Script output follows |
|
8 | 200 Script output follows | |
9 | ---- DATA |
|
9 | ---- DATA | |
10 |
[('Content- |
|
10 | [('Content-Type', 'application/atom+xml; charset=ascii')] | |
11 | <?xml version="1.0" encoding="ascii"?> |
|
11 | <?xml version="1.0" encoding="ascii"?> | |
12 | <feed xmlns="http://www.w3.org/2005/Atom"> |
|
12 | <feed xmlns="http://www.w3.org/2005/Atom"> | |
13 | <!-- Changelog --> |
|
13 | <!-- Changelog --> | |
@@ -41,7 +41,7 b' 200 Script output follows' | |||||
41 | ---- HEADERS |
|
41 | ---- HEADERS | |
42 | 200 Script output follows |
|
42 | 200 Script output follows | |
43 | ---- DATA |
|
43 | ---- DATA | |
44 |
[('Content- |
|
44 | [('Content-Type', 'text/plain; charset=ascii')] | |
45 |
|
45 | |||
46 | -rw-r--r-- 4 bar |
|
46 | -rw-r--r-- 4 bar | |
47 |
|
47 | |||
@@ -52,7 +52,7 b' 200 Script output follows' | |||||
52 | ---- HEADERS |
|
52 | ---- HEADERS | |
53 | 200 Script output follows |
|
53 | 200 Script output follows | |
54 | ---- DATA |
|
54 | ---- DATA | |
55 |
[('Content- |
|
55 | [('Content-Type', 'text/plain; charset=ascii')] | |
56 |
|
56 | |||
57 | /repo/ |
|
57 | /repo/ | |
58 |
|
58 | |||
@@ -62,7 +62,7 b' 200 Script output follows' | |||||
62 | ---- HEADERS |
|
62 | ---- HEADERS | |
63 | 200 Script output follows |
|
63 | 200 Script output follows | |
64 | ---- DATA |
|
64 | ---- DATA | |
65 |
[('Content- |
|
65 | [('Content-Type', 'text/plain; charset=ascii')] | |
66 |
|
66 | |||
67 | -rw-r--r-- 4 bar |
|
67 | -rw-r--r-- 4 bar | |
68 |
|
68 |
General Comments 0
You need to be logged in to leave comments.
Login now