コード例 #1
0
ファイル: test_http.py プロジェクト: benoitc/gunicorn
def test_iter_unreader_chunk():
    iter_unreader = IterUnreader((b'ab', b'cd', b'ef'))

    assert iter_unreader.chunk() == b'ab'
    assert iter_unreader.chunk() == b'cd'
    assert iter_unreader.chunk() == b'ef'
    assert iter_unreader.chunk() == b''
    assert iter_unreader.chunk() == b''
コード例 #2
0
def test_iter_unreader_chunk():
    iter_unreader = IterUnreader((b'ab', b'cd', b'ef'))

    assert iter_unreader.chunk() == b'ab'
    assert iter_unreader.chunk() == b'cd'
    assert iter_unreader.chunk() == b'ef'
    assert iter_unreader.chunk() == b''
    assert iter_unreader.chunk() == b''
コード例 #3
0
 def __init__(self, mesg_class, source):
     self.mesg_class = mesg_class
     if hasattr(source, "recv"):
         self.unreader = SocketUnreader(source)
     else:
         self.unreader = IterUnreader(source)
     self.mesg = None
コード例 #4
0
ファイル: parser.py プロジェクト: luog1992/gunicorn
 def __init__(self, cfg, source):
     self.cfg = cfg
     if hasattr(source, "recv"):
         self.unreader = SocketUnreader(source)
     else:
         self.unreader = IterUnreader(source)
     self.mesg = None
     # request counter (for keepalive connections)
     self.req_count = 0
コード例 #5
0
def test_eof_reader_read():
    unreader = IterUnreader((b'Lorem', b'ipsum', b'dolor', b'sit', b'amet'))
    reader = EOFReader(unreader)

    assert reader.read(0) == b''
    assert reader.read(5) == b'Lorem'
    assert reader.read(5) == b'ipsum'
    assert reader.read(3) == b'dol'
    assert reader.read(3) == b'ors'
    assert reader.read(100) == b'itamet'
    assert reader.read(100) == b''
コード例 #6
0
def test_length_reader_read():
    unreader = IterUnreader((b'Lorem', b'ipsum', b'dolor', b'sit', b'amet'))
    reader = LengthReader(unreader, 13)
    assert reader.read(0) == b''
    assert reader.read(5) == b'Lorem'
    assert reader.read(6) == b'ipsumd'
    assert reader.read(4) == b'ol'
    assert reader.read(100) == b''

    reader = LengthReader(unreader, 10)
    assert reader.read(0) == b''
    assert reader.read(5) == b'orsit'
    assert reader.read(5) == b'amet'
    assert reader.read(100) == b''