webob will tack on 'charset: utf-8' for certain content-types (text/plain, startswith: text/, application/, etc) when initialized with a content-type. swift stores the content-type as passed by the client in the xattrs which was then used in the initializer for the Response in the object server. This could cause extra charsets to be appended in certain conditions. The change involves taking the content-type out of the initializer and assigning it directly to what is in the xattrs. this bypasses the webob charset addition.

This commit is contained in:
Scott Simpson 2011-07-13 21:17:29 +00:00 committed by Tarmac
commit 5b882e08a1

View File

@ -607,9 +607,10 @@ class ObjectController(object):
if_modified_since:
file.close()
return HTTPNotModified(request=request)
response = Response(content_type=file.metadata.get('Content-Type',
'application/octet-stream'), app_iter=file,
response = Response(app_iter=file,
request=request, conditional_response=True)
response.headers['Content-Type'] = file.metadata.get('Content-Type',
'application/octet-stream')
for key, value in file.metadata.iteritems():
if key.lower().startswith('x-object-meta-') or \
key.lower() in self.allowed_headers:
@ -647,8 +648,9 @@ class ObjectController(object):
except (DiskFileError, DiskFileNotExist):
file.quarantine()
return HTTPNotFound(request=request)
response = Response(content_type=file.metadata['Content-Type'],
request=request, conditional_response=True)
response = Response(request=request, conditional_response=True)
response.headers['Content-Type'] = file.metadata.get('Content-Type',
'application/octet-stream')
for key, value in file.metadata.iteritems():
if key.lower().startswith('x-object-meta-') or \
key.lower() in self.allowed_headers: