Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

created test for body_or_str and made small improvement to scrapy.http.response

samus_d706182e97f0
diff --git a/scrapy/trunk/scrapy/http/response.py b/scrapy/trunk/scrapy/http/response.py
index 0ec3a2f4b..594f684d7 100644
--- a/scrapy/trunk/scrapy/http/response.py
+++ b/scrapy/trunk/scrapy/http/response.py
@@ -29,10 +29,11 @@ class Response(object) :
self.original_url = Url(original_url) if original_url else url # different if redirected or escaped
self.headers = Headers(headers or {})
self.status = status
- if isinstance(body, str):
- self.body = ResponseBody(body, self.headers_encoding())
- else:
+ # FIXME this should be replaced with assert(isinstance(body, basestring)) since ResponseBody is not meant to be used directly
+ if isinstance(body, ResponseBody):
self.body = body
+ else:
+ self.body = ResponseBody(body, self.headers_encoding())
self.cached = False
self.request = None # request which originated this response