'Create a stream header to be received by the test XMPP agent.
The header must be saved and passed to stream_start.
Arguments:
sto        -- The recipient of the stream header.
sfrom      -- The agent sending the stream header.
sid        -- The stream\'s id.
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.'

def make_header(self, sto='', sfrom='', sid='', stream_ns='http://etherx.jabber.org/streams', default_ns='jabber:client', default_lang='en', version='1.0', xml_header=True):

    header = '<stream:stream    %s>'
    parts = []
    if xml_header:
        header = ('<?xml    version="1.0"?>' + header)
    if sto:
        parts.append(('to="%s"' % sto))
    if sfrom:
        parts.append(('from="%s"' % sfrom))
    if sid:
        parts.append(('id="%s"' % sid))
    if default_lang:
        parts.append(('xml:lang="%s"' % default_lang))
    parts.append(('version="%s"' % version))
    parts.append(('xmlns:stream="%s"' % stream_ns))
    parts.append(('xmlns="%s"' % default_ns))
    return (header % '    '.join(parts))
