Пример #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')
Пример #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())
Пример #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')
Пример #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())
Пример #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))
Пример #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])
Пример #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))
Пример #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])
Пример #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, '')
Пример #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, '')