Ensure only single content-type header when using json post-processor

This commit is contained in:
Kovid Goyal 2015-12-21 15:47:43 +05:30
parent e3c8ab98b1
commit b14405e6a1

View File

@ -17,7 +17,7 @@ from calibre.srv.utils import http_date
default_methods = frozenset(('HEAD', 'GET')) default_methods = frozenset(('HEAD', 'GET'))
def json(ctx, rd, endpoint, output): def json(ctx, rd, endpoint, output):
rd.outheaders['Content-Type'] = 'application/json; charset=UTF-8' rd.outheaders.set('Content-Type', 'application/json; charset=UTF-8', replace_all=True)
if isinstance(output, bytes): if isinstance(output, bytes):
ans = output # Assume output is already UTF-8 encoded json ans = output # Assume output is already UTF-8 encoded json
else: else: