Exemplo n.º 1
0
 def test_http_response_parser_bad_status_line(self):
     p = protocol.http_response_parser()
     next(p)
     out = tulip.DataBuffer()
     buf = tulip.ParserBuffer()
     p.send((out, buf))
     self.assertRaises(errors.BadStatusLine, p.send, b'\r\n\r\n')
Exemplo n.º 2
0
 def test_http_response_parser_bad_status_line_eof(self):
     p = protocol.http_response_parser()
     next(p)
     out = tulip.DataBuffer()
     buf = tulip.ParserBuffer()
     p.send((out, buf))
     self.assertRaises(errors.BadStatusLine, p.throw, tulip.EofStream())
Exemplo n.º 3
0
 def test_http_response_parser_bad_status_line(self):
     p = protocol.http_response_parser()
     next(p)
     out = tulip.DataBuffer()
     buf = tulip.ParserBuffer()
     p.send((out, buf))
     self.assertRaises(errors.BadStatusLine, p.send, b'\r\n\r\n')
Exemplo n.º 4
0
 def test_http_response_parser_bad_status_line_eof(self):
     p = protocol.http_response_parser()
     next(p)
     out = tulip.DataBuffer()
     buf = tulip.ParserBuffer()
     p.send((out, buf))
     self.assertRaises(
         errors.BadStatusLine, p.throw, tulip.EofStream())
Exemplo n.º 5
0
 def test_http_response_parser_code_not_int(self):
     p = protocol.http_response_parser()
     next(p)
     out = tulip.DataBuffer()
     buf = tulip.ParserBuffer()
     p.send((out, buf))
     with self.assertRaises(errors.BadStatusLine) as cm:
         p.send(b'HTTP/1.1 ttt test\r\n\r\n')
     self.assertIn('HTTP/1.1 ttt test', str(cm.exception))
Exemplo n.º 6
0
 def test_http_response_parser_bad_version(self):
     p = protocol.http_response_parser()
     next(p)
     out = tulip.DataBuffer()
     buf = tulip.ParserBuffer()
     p.send((out, buf))
     with self.assertRaises(errors.BadStatusLine) as cm:
         p.send(b'HT/11 200 Ok\r\n\r\n')
     self.assertEqual('HT/11 200 Ok\r\n', cm.exception.args[0])
Exemplo n.º 7
0
 def test_http_response_parser_code_not_int(self):
     p = protocol.http_response_parser()
     next(p)
     out = tulip.DataBuffer()
     buf = tulip.ParserBuffer()
     p.send((out, buf))
     with self.assertRaises(errors.BadStatusLine) as cm:
         p.send(b'HTTP/1.1 ttt test\r\n\r\n')
     self.assertIn('HTTP/1.1 ttt test', str(cm.exception))
Exemplo n.º 8
0
 def test_http_response_parser_bad_version(self):
     p = protocol.http_response_parser()
     next(p)
     out = tulip.DataBuffer()
     buf = tulip.ParserBuffer()
     p.send((out, buf))
     with self.assertRaises(errors.BadStatusLine) as cm:
         p.send(b'HT/11 200 Ok\r\n\r\n')
     self.assertEqual('HT/11 200 Ok\r\n', cm.exception.args[0])
Exemplo n.º 9
0
 def test_http_response_parser_no_reason(self):
     p = protocol.http_response_parser()
     next(p)
     out = tulip.DataBuffer()
     buf = tulip.ParserBuffer()
     p.send((out, buf))
     try:
         p.send(b'HTTP/1.1 200\r\n\r\n')
     except StopIteration:
         pass
     v, s, r = out._buffer[0][:3]
     self.assertEqual(v, (1, 1))
     self.assertEqual(s, 200)
     self.assertEqual(r, '')
Exemplo n.º 10
0
 def test_http_response_parser_no_reason(self):
     p = protocol.http_response_parser()
     next(p)
     out = tulip.DataBuffer()
     buf = tulip.ParserBuffer()
     p.send((out, buf))
     try:
         p.send(b'HTTP/1.1 200\r\n\r\n')
     except StopIteration:
         pass
     v, s, r = out._buffer[0][:3]
     self.assertEqual(v, (1, 1))
     self.assertEqual(s, 200)
     self.assertEqual(r, '')