(self)
Iterate over a binary file-like object line by line. Each line is
            returned as a (line, line_ending) tuple. If the line does not fit
            into self.buffer_size, line_ending is empty and the rest of the line
            is returned with the next iteration.
Iterate over a binary file-like object line by line. Each line is
            returned as a (line, line_ending) tuple. If the line does not fit
            into self.buffer_size, line_ending is empty and the rest of the line
            is returned with the next iteration.
Iterate over a binary file - like object line by line . Each line is returned as a ( line line_ending ) tuple . If the line does not fit into self . buffer_size line_ending is empty and the rest of the line is returned with the next iteration .
def _lineiter(self):
        ''' Iterate over a binary file-like object line by line. Each line is
            returned as a (line, line_ending) tuple. If the line does not fit
            into self.buffer_size, line_ending is empty and the rest of the line
            is returned with the next iteration.
        '''
        read = self.stream.read
        maxread, maxbuf = self.content_length, self.buffer_size
        _bcrnl = tob('\r\n')
        _bcr = _bcrnl[:1]
        _bnl = _bcrnl[1:]
        _bempty = _bcrnl[:0]  # b'rn'[:0] -> b''
        buffer = _bempty  # buffer for the last (partial) line
        while 1:
            data = read(maxbuf if maxread < 0 else min(maxbuf, maxread))
            maxread -= len(data)
            lines = (buffer + data).splitlines(True)
            len_first_line = len(lines[0])
            # be sure that the first line does not become too big
            if len_first_line > self.buffer_size:
                # at the same time don't split a '\r\n' accidentally
                if (len_first_line == self.buffer_size + 1 and
                        lines[0].endswith(_bcrnl)):
                    splitpos = self.buffer_size - 1
                else:
                    splitpos = self.buffer_size
                lines[:1] = [lines[0][:splitpos],
                             lines[0][splitpos:]]
            if data:
                buffer = lines[-1]
                lines = lines[:-1]
            for line in lines:
                if line.endswith(_bcrnl):
                    yield line[:-2], _bcrnl
                elif line.endswith(_bnl):
                    yield line[:-1], _bnl
                elif line.endswith(_bcr):
                    yield line[:-1], _bcr
                else:
                    yield line, _bempty
            if not data:
                break
def _lineiter ( self ) : read = self . stream . read maxread , maxbuf = self . content_length , self . buffer_size _bcrnl = tob ( '\r\n' ) _bcr = _bcrnl [ : 1 ] _bnl = _bcrnl [ 1 : ] _bempty = _bcrnl [ : 0 ] # b'rn'[:0] -> b'' buffer = _bempty # buffer for the last (partial) line while 1 : data = read ( maxbuf if maxread < 0 else min ( maxbuf , maxread ) ) maxread -= len ( data ) lines = ( buffer + data ) . splitlines ( True ) len_first_line = len ( lines [ 0 ] ) # be sure that the first line does not become too big if len_first_line > self . buffer_size : # at the same time don't split a '\r\n' accidentally if ( len_first_line == self . buffer_size + 1 and lines [ 0 ] . endswith ( _bcrnl ) ) : splitpos = self . buffer_size - 1 else : splitpos = self . buffer_size lines [ : 1 ] = [ lines [ 0 ] [ : splitpos ] , lines [ 0 ] [ splitpos : ] ] if data : buffer = lines [ - 1 ] lines = lines [ : - 1 ] for line in lines : if line . endswith ( _bcrnl ) : yield line [ : - 2 ] , _bcrnl elif line . endswith ( _bnl ) : yield line [ : - 1 ] , _bnl elif line . endswith ( _bcr ) : yield line [ : - 1 ] , _bcr else : yield line , _bempty if not data : break