Merge lp:~sasimpson/swift/lp803141 into lp:~hudson-openstack/swift/trunk

Proposed by Scott Simpson
Status: Merged
Approved by: John Dickinson
Approved revision: 321
Merged at revision: 324
Proposed branch: lp:~sasimpson/swift/lp803141
Merge into: lp:~hudson-openstack/swift/trunk
Diff against target: 28 lines (+6/-4)
1 file modified
swift/obj/server.py (+6/-4)
To merge this branch: bzr merge lp:~sasimpson/swift/lp803141
Reviewer Review Type Date Requested Status
John Dickinson Approve
David Goetz (community) Approve
Review via email: mp+67738@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
Revision history for this message
David Goetz (david-goetz) wrote :

looks good to me

review: Approve
Revision history for this message
John Dickinson (notmyname) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'swift/obj/server.py'
2--- swift/obj/server.py 2011-06-07 23:19:48 +0000
3+++ swift/obj/server.py 2011-07-12 18:09:31 +0000
4@@ -607,9 +607,10 @@
5 if_modified_since:
6 file.close()
7 return HTTPNotModified(request=request)
8- response = Response(content_type=file.metadata.get('Content-Type',
9- 'application/octet-stream'), app_iter=file,
10+ response = Response(app_iter=file,
11 request=request, conditional_response=True)
12+ response.headers['Content-Type'] = file.metadata.get('Content-Type',
13+ 'application/octet-stream')
14 for key, value in file.metadata.iteritems():
15 if key.lower().startswith('x-object-meta-') or \
16 key.lower() in self.allowed_headers:
17@@ -647,8 +648,9 @@
18 except (DiskFileError, DiskFileNotExist):
19 file.quarantine()
20 return HTTPNotFound(request=request)
21- response = Response(content_type=file.metadata['Content-Type'],
22- request=request, conditional_response=True)
23+ response = Response(request=request, conditional_response=True)
24+ response.headers['Content-Type'] = file.metadata.get('Content-Type',
25+ 'application/octet-stream')
26 for key, value in file.metadata.iteritems():
27 if key.lower().startswith('x-object-meta-') or \
28 key.lower() in self.allowed_headers: