Exemplo n.º 1
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.º 2
0
 def test_http_payload_parser_eof(self):
     msg = protocol.RawRequestMessage('GET', '/', (1, 1), [], None, None)
     p = protocol.http_payload_parser(msg, readall=True)
     next(p)
     out = tulip.DataBuffer()
     buf = tulip.ParserBuffer()
     p.send((out, buf))
     p.send(b'data')
     p.send(b'line')
     self.assertRaises(tulip.EofStream, p.throw, tulip.EofStream())
     self.assertEqual(b'dataline', b''.join(out._buffer))
Exemplo n.º 3
0
    def test_parse_eof_payload(self):
        out = tulip.DataBuffer()
        buf = tulip.ParserBuffer()
        p = protocol.parse_eof_payload(out, buf)
        next(p)
        p.send(b'data')
        try:
            p.throw(tulip.EofStream())
        except tulip.EofStream:
            pass

        self.assertEqual([b'data'], list(out._buffer))
Exemplo n.º 4
0
 def test_http_request_parser_eof(self):
     # http_request_parser does not fail on EofStream()
     p = protocol.http_request_parser()
     next(p)
     out = tulip.DataBuffer()
     buf = tulip.ParserBuffer()
     p.send((out, buf))
     p.send(b'get /path HTTP/1.1\r\n')
     try:
         p.throw(tulip.EofStream())
     except StopIteration:
         pass
     self.assertFalse(out._buffer)
Exemplo n.º 5
0
 def write_eof(self):
     self.write(EOF_MARKER)
     try:
         self.writer.throw(tulip.EofStream())
     except StopIteration:
         pass