This commit is contained in:
Kovid Goyal 2015-05-19 17:15:39 +05:30
parent 4495368d9e
commit 6daed59a8f
2 changed files with 8 additions and 8 deletions

View File

@ -97,7 +97,7 @@ class DynamicOutput(object):
ct = outheaders.get('Content-Type', 'text/plain') ct = outheaders.get('Content-Type', 'text/plain')
if 'charset=' not in ct: if 'charset=' not in ct:
ct += '; charset=UTF-8' ct += '; charset=UTF-8'
outheaders.set('Content-Type', ct, replace=True) outheaders.set('Content-Type', ct, replace_all=True)
self.content_length = len(self.data) self.content_length = len(self.data)
self.etag = None self.etag = None
self.accept_ranges = False self.accept_ranges = False
@ -173,16 +173,16 @@ def finalize_output(output, inheaders, outheaders, status_code, is_http1, method
# TODO: Ranges, If-Range # TODO: Ranges, If-Range
if output.etag and method in ('GET', 'HEAD'): if output.etag and method in ('GET', 'HEAD'):
outheaders.set('ETag', output.etag, replace=True) outheaders.set('ETag', output.etag, replace_all=True)
if accept_ranges: if accept_ranges:
outheaders.set('Accept-Ranges', 'bytes', replace=True) outheaders.set('Accept-Ranges', 'bytes', replace_all=True)
elif compressible: elif compressible:
outheaders.set('Content-Encoding', 'gzip', replace=True) outheaders.set('Content-Encoding', 'gzip', replace_all=True)
if output.content_length is not None and not compressible and not ranges: if output.content_length is not None and not compressible and not ranges:
outheaders.set('Content-Length', '%d' % output.content_length, replace=True) outheaders.set('Content-Length', '%d' % output.content_length, replace_all=True)
if compressible or output.content_length is None: if compressible or output.content_length is None:
outheaders.set('Transfer-Encoding', 'chunked', replace=True) outheaders.set('Transfer-Encoding', 'chunked', replace_all=True)
output.commit = output.write_compressed if compressible else output.write output.commit = output.write_compressed if compressible else output.write

View File

@ -53,8 +53,8 @@ class MultiDict(dict): # {{{
yield v[-1] yield v[-1]
itervalues = values itervalues = values
def set(self, key, val, replace=False): def set(self, key, val, replace_all=False):
if replace: if replace_all:
dict.__setitem__(self, key, [val]) dict.__setitem__(self, key, [val])
else: else:
self[key] = val self[key] = val