'Check that a given stream header was received.
Arguments:
sto        -- The recipient of the stream header.
sfrom      -- The agent sending the stream header.
sid        -- The stream\'s id. Set to None to ignore.
stream_ns  -- The namespace of the stream\'s root element.
default_ns -- The default stanza namespace.
version    -- The stream version.
xml_header -- Indicates if the XML version header should be
appended before the stream header.
timeout    -- Length of time to wait in seconds for a
response.'

def recv_header(self, sto='', sfrom='', sid='', stream_ns='http://etherx.jabber.org/streams', default_ns='jabber:client', version='1.0', xml_header=False, timeout=1):

    header = self.make_header(sto, sfrom, sid, stream_ns=stream_ns, default_ns=default_ns, version=version, xml_header=xml_header)
    recv_header = self.xmpp.socket.next_recv(timeout)
    if (recv_header is None):
        raise ValueError('Socket    did    not    return    data.')
    header2 = (header + '</stream:stream>')
    recv_header2 = (recv_header + '</stream:stream>')
    xml = self.parse_xml(header2)
    recv_xml = self.parse_xml(recv_header2)
    if (sid is None):
        if ('id' in recv_xml.attrib):
            del recv_xml.attrib['id']
    if ('xml:lang' in recv_xml.attrib):
        del recv_xml.attrib['xml:lang']
    xml_ns = 'http://www.w3.org/XML/1998/namespace'
    if (('{%s}lang' % xml_ns) in recv_xml.attrib):
        del recv_xml.attrib[('{%s}lang' % xml_ns)]
    if list(recv_xml):
        for xml in recv_xml:
            self.xmpp.socket.recv_data(tostring(xml))
        attrib = recv_xml.attrib
        recv_xml.clear()
        recv_xml.attrib = attrib
    self.failUnless(self.compare(xml, recv_xml), ('Stream    headers    do    not    match:\nDesired:\n%s\nReceived:\n%s' % (('%s    %s' % (xml.tag, xml.attrib)), ('%s    %s' % (recv_xml.tag, recv_xml.attrib)))))
