def _test(self, factory, testvalue):
     transport = StringTransport()
     protocol = CrawlmiHTTPClient()
     protocol.factory = factory
     protocol.makeConnection(transport)
     self.assertEqual(transport.value(), testvalue)
 def test_invalid_status(self):
     transport = StringTransport()
     factory = CrawlmiHTPPClientFactory(Request(url='http://foo/bar'))
     protocol = CrawlmiHTTPClient()
     protocol.factory = factory
     protocol.makeConnection(transport)
     protocol.headers = Headers()
     protocol.dataReceived('HTTP/1.0 BUG OK\r\n')
     protocol.dataReceived('Hello: World\r\n')
     protocol.dataReceived('Foo: Bar\r\n')
     protocol.dataReceived('\r\n')
     protocol.handleResponse('')
     return self.assertFailure(factory.deferred, BadHttpHeaderError)
 def test_non_standard_line_endings(self):
     factory = CrawlmiHTPPClientFactory(Request(url='http://foo/bar'))
     protocol = CrawlmiHTTPClient()
     protocol.factory = factory
     protocol.headers = Headers()
     protocol.dataReceived('HTTP/1.0 200 OK\n')
     protocol.dataReceived('Hello: World\n')
     protocol.dataReceived('Foo: Bar\n')
     protocol.dataReceived('\n')
     self.assertEqual(protocol.headers,
                      Headers({
                          'Hello': ['World'],
                          'Foo': ['Bar']
                      }))
Beispiel #4
0
 def _test(self, factory, testvalue):
     transport = StringTransport()
     protocol = CrawlmiHTTPClient()
     protocol.factory = factory
     protocol.makeConnection(transport)
     self.assertEqual(transport.value(), testvalue)
Beispiel #5
0
 def test_invalid_status(self):
     transport = StringTransport()
     factory = CrawlmiHTPPClientFactory(Request(url='http://foo/bar'))
     protocol = CrawlmiHTTPClient()
     protocol.factory = factory
     protocol.makeConnection(transport)
     protocol.headers = Headers()
     protocol.dataReceived('HTTP/1.0 BUG OK\r\n')
     protocol.dataReceived('Hello: World\r\n')
     protocol.dataReceived('Foo: Bar\r\n')
     protocol.dataReceived('\r\n')
     protocol.handleResponse('')
     return self.assertFailure(factory.deferred, BadHttpHeaderError)
Beispiel #6
0
 def test_non_standard_line_endings(self):
     factory = CrawlmiHTPPClientFactory(Request(url='http://foo/bar'))
     protocol = CrawlmiHTTPClient()
     protocol.factory = factory
     protocol.headers = Headers()
     protocol.dataReceived('HTTP/1.0 200 OK\n')
     protocol.dataReceived('Hello: World\n')
     protocol.dataReceived('Foo: Bar\n')
     protocol.dataReceived('\n')
     self.assertEqual(protocol.headers,
         Headers({'Hello': ['World'], 'Foo': ['Bar']}))