示例#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, '')