Example #1
0
 def test_decode_chunked_transfer(self):
     """Example taken from: http://en.wikipedia.org/wiki/Chunked_transfer_encoding"""
     chunked_body = "25\r\n" + "This is the data in the first chunk\r\n\r\n"
     chunked_body += "1C\r\n" + "and this is the second one\r\n\r\n"
     chunked_body += "3\r\n" + "con\r\n"
     chunked_body += "8\r\n" + "sequence\r\n"
     chunked_body += "0\r\n\r\n"
     body = decode_chunked_transfer(chunked_body)
     self.assertEqual(body, \
         "This is the data in the first chunk\r\n" +
         "and this is the second one\r\n" +
         "consequence")
Example #2
0
 def test_decode_chunked_transfer(self):
     """Example taken from: http://en.wikipedia.org/wiki/Chunked_transfer_encoding"""
     chunked_body = "25\r\n" + "This is the data in the first chunk\r\n\r\n"
     chunked_body += "1C\r\n" + "and this is the second one\r\n\r\n"
     chunked_body += "3\r\n" + "con\r\n"
     chunked_body += "8\r\n" + "sequence\r\n"
     chunked_body += "0\r\n\r\n"
     body = decode_chunked_transfer(chunked_body)
     self.assertEqual(body,
                      "This is the data in the first chunk\r\n" +
         "and this is the second one\r\n" +
         "consequence")
Example #3
0
 def process_response(self, request, response, spider):
     if response.headers.get('Transfer-Encoding') == 'chunked':
         body = decode_chunked_transfer(response.body)
         return response.replace(body=body)
     return response
Example #4
0
 def process_response(self, request, response, spider):
     if response.headers.get('Transfer-Encoding') == 'chunked':
         body = decode_chunked_transfer(response.body)
         return response.replace(body=body)
     return response