Esempio n. 1
0
 def parse_request(self, *chunks):
     # Parse the HTTP request made up of *chunks.
     transport = MockTransport()
     protocol = HttpProtocol(self.store_request, server_side=True)
     transport.start(protocol)
     for chunk in chunks:
         protocol.data_received(chunk)
     self.assertIsNone(protocol._error)
     self.transport = transport
     self.protocol = protocol
Esempio n. 2
0
 def parse_request(self, *chunks):
     # Parse the HTTP request made up of *chunks.
     transport = MockTransport()
     protocol = HttpProtocol(self.store_request, server_side=True)
     transport.start(protocol)
     for chunk in chunks:
         protocol.data_received(chunk)
     self.assertIsNone(protocol._error)
     self.transport = transport
     self.protocol = protocol
Esempio n. 3
0
 def parse_response(self, *chunks, **kwargs):
     # Parse the HTTP resposne made up of *chunks.
     transport = MockTransport()
     protocol = HttpProtocol()
     transport.start(protocol)
     methods = kwargs.get('methods', [])
     if methods:
         protocol._requests = methods
     for chunk in chunks:
         protocol.data_received(chunk)
     self.assertIsNone(protocol._error)
     self.transport = transport
     self.protocol = protocol
Esempio n. 4
0
 def parse_response(self, *chunks, **kwargs):
     # Parse the HTTP resposne made up of *chunks.
     transport = MockTransport()
     protocol = HttpProtocol()
     transport.start(protocol)
     methods = kwargs.get('methods', [])
     if methods:
         protocol._requests = methods
     for chunk in chunks:
         protocol.data_received(chunk)
     self.assertIsNone(protocol._error)
     self.transport = transport
     self.protocol = protocol
Esempio n. 5
0
 def perf_parsing_speed(self):
     transport = MockTransport()
     protocol = HttpProtocol()
     transport.start(protocol)
     r = b'HTTP/1.1 200 OK\r\nContent-Length: 10000\r\n\r\n'
     r += b'x' * 10000
     reqs = 4 * r
     nbytes = 0
     t0 = t1 = time.time()
     while t1 - t0 < 1.0:
         protocol.data_received(reqs)
         del protocol._queue._heap[:]
         nbytes += len(reqs)
         t1 = time.time()
     speed = nbytes / (t1 - t0) / (1024 * 1024)
     self.add_result(speed)
Esempio n. 6
0
 def perf_parsing_speed(self):
     transport = MockTransport()
     protocol = HttpProtocol()
     transport.start(protocol)
     r = b'HTTP/1.1 200 OK\r\nContent-Length: 10000\r\n\r\n'
     r += b'x' * 10000
     reqs = 4 * r
     nbytes = 0
     t0 = t1 = time.time()
     while t1 - t0 < 0.2:
         protocol.data_received(reqs)
         del protocol._queue._heap[:]
         nbytes += len(reqs)
         t1 = time.time()
     speed = nbytes / (t1 - t0) / (1024 * 1024)
     self.add_result(speed)