'Reads a line from the SSYNC response body.
httplib has no readline and will block on read(x) until x is
read, so we have to do the work ourselves. A bit of this is
taken from Python\'s httplib itself.'

def readline(self):

    data = self.response_buffer
    self.response_buffer = ''
    while (('\n' not in data) and (len(data) < self.daemon.network_chunk_size)):
        if (self.response_chunk_left == (-1)):
            break
        if (self.response_chunk_left == 0):
            line = self.response.fp.readline()
            i = line.find(';')
            if (i >= 0):
                line = line[:i]
            try:
                self.response_chunk_left = int(line.strip(), 16)
            except ValueError:
                self.response.close()
                raise exceptions.ReplicationException('Early    disconnect')
            if (self.response_chunk_left == 0):
                self.response_chunk_left = (-1)
                break
        chunk = self.response.fp.read(min(self.response_chunk_left, (self.daemon.network_chunk_size - len(data))))
        if (not chunk):
            self.response.close()
            raise exceptions.ReplicationException('Early    disconnect')
        self.response_chunk_left -= len(chunk)
        if (self.response_chunk_left == 0):
            self.response.fp.read(2)
        data += chunk
    if ('\n' in data):
        (data, self.response_buffer) = data.split('\n', 1)
        data += '\n'
    return data
