Permalink
Browse files

Be less aggressive with processing the response content

  • Loading branch information...
1 parent 04330a1 commit 04b8902d4759775937e76165be16a5375933c9d5 @bruth committed Jun 7, 2012
Showing with 8 additions and 6 deletions.
  1. +8 −6 restlib2/resources.py
View
@@ -376,16 +376,18 @@ def process_response(self, request, response):
content = response
response = HttpResponse()
+ accept_type = getattr(request, '_accept_type', None)
+
# If the response already has a `_raw_content` attribute, do not
# bother with the local content.
- if content is not None:
- if not isinstance(content, basestring) and hasattr(request, '_accept_type'):
+ if content != '':
+ if not isinstance(content, basestring) and serializers.supports_encoding(accept_type):
# Encode the body
- content = serializers.encode(request._accept_type, content)
- response['Content-Type'] = request._accept_type
-
+ content = serializers.encode(accept_type, content)
+ response['Content-Type'] = accept_type
response.content = content
- content_length = len(response.content)
+
+ content_length = len(response.content)
if content_length == 0:
del response['Content-Type']

0 comments on commit 04b8902

Please sign in to comment.