'Return the value of the first occurence of the given header.
Header name is case-insensitive.
Arguments:
- contents: message itself
- name: name of the header to be searched
Returns: header value or None if no such header was found.'

def getmessageheader(self, content, name):

    self.ui.debug('', ('getmessageheader:    called    to    get    %s' % name))
    eoh = self.__find_eoh(content)
    self.ui.debug('', ('getmessageheader:    eoh    =    %d' % eoh))
    headers = content[0:eoh]
    self.ui.debug('', ('getmessageheader:    headers    =    %s' % repr(headers)))
    m = re.search(('^%s:(.*)$' % name), headers, flags=(re.MULTILINE | re.IGNORECASE))
    if m:
        return m.group(1).strip()
    else:
        return None
