Changeset 1808:7dc0284d871a

Show
Ignore:
Timestamp:
10/21/09 13:57:06 (11 months ago)
Author:
Daniel Grana <dangra@…>
Branch:
default
Message:

fix get_meta_refresh bug raised for TextResponses? without encoding

Location:
scrapy
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • scrapy/tests/test_utils_response.py

    r1804 r1808  
    9494        self.assertEqual(get_meta_refresh(response), (3, 'http://example.com/thisTHAT')) 
    9595 
     96        # responses without refresh tag should return None None 
     97        response = Response(url='http://example.org') 
     98        self.assertEqual(get_meta_refresh(response), (None, None)) 
     99        response = TextResponse(url='http://example.org') 
     100        self.assertEqual(get_meta_refresh(response), (None, None)) 
     101 
    96102    def test_response_httprepr(self): 
    97103        r1 = Response("http://www.example.com") 
  • scrapy/utils/response.py

    r1804 r1808  
    4848    """ 
    4949    if response not in _metaref_cache: 
    50         encoding = getattr(response, 'encoding', 'utf-8') 
     50        encoding = getattr(response, 'encoding', None) or 'utf-8' 
    5151        body_chunk = remove_entities(unicode(response.body[0:4096], encoding, \ 
    5252            errors='ignore'))