Example #1
0
    def test_response_httprepr(self):
        r1 = Response('http://www.example.com')
        self.assertEqual(response_http_repr(r1), 'HTTP/1.1 200 OK\r\n\r\n')

        r1 = Response('http://www.example.com', status=404, headers={'Content-type': 'text/html'}, body='Some body')
        self.assertEqual(response_http_repr(r1), 'HTTP/1.1 404 Not Found\r\nContent-Type: text/html\r\n\r\nSome body')

        r1 = Response('http://www.example.com', status=6666, headers={'Content-type': 'text/html'}, body='Some body')
        self.assertEqual(response_http_repr(r1), 'HTTP/1.1 6666 \r\nContent-Type: text/html\r\n\r\nSome body')
 def process_response(self, response):
     self.stats.inc_value('downloader/response_count')
     self.stats.inc_value('downloader/response_status_count/%s' %
                          response.status)
     resp_len = len(response_http_repr(response))
     self.stats.inc_value('downloader/response_bytes', resp_len)
     return response
    def test_response_httprepr(self):
        r1 = Response('http://www.example.com')
        self.assertEqual(response_http_repr(r1), 'HTTP/1.1 200 OK\r\n\r\n')

        r1 = Response('http://www.example.com',
                      status=404,
                      headers={'Content-type': 'text/html'},
                      body='Some body')
        self.assertEqual(
            response_http_repr(r1),
            'HTTP/1.1 404 Not Found\r\nContent-Type: text/html\r\n\r\nSome body'
        )

        r1 = Response('http://www.example.com',
                      status=6666,
                      headers={'Content-type': 'text/html'},
                      body='Some body')
        self.assertEqual(
            response_http_repr(r1),
            'HTTP/1.1 6666 \r\nContent-Type: text/html\r\n\r\nSome body')
Example #4
0
 def process_response(self, response):
     self.stats.inc_value('downloader/response_count')
     self.stats.inc_value('downloader/response_status_count/%s' % response.status)
     resp_len = len(response_http_repr(response))
     self.stats.inc_value('downloader/response_bytes', resp_len)
     return response