'prefix is ignored if add_to_http_hdrs is true.'

def addheader(self, key, value, prefix=0, add_to_http_hdrs=0):

    lines = value.split('\r\n')
    while (lines and (not lines[(-1)])):
        del lines[(-1)]
    while (lines and (not lines[0])):
        del lines[0]
    if add_to_http_hdrs:
        value = ''.join(lines)
        self._http_hdrs.append((key.capitalize(), value))
    else:
        for i in xrange(1, len(lines)):
            lines[i] = ('                ' + lines[i].strip())
        value = ('\r\n'.join(lines) + '\r\n')
        line = ((key.title() + ':    ') + value)
        if prefix:
            self._headers.insert(0, line)
        else:
            self._headers.append(line)
