Exemplo n.º 1
0
def _write_headers(headers, output):
    header_count = len(headers)
    amf0.write_int(header_count, output)
    for header in headers:
        context = amf.AMFMessageBodyContext()
        amf0.write_utf(header['name'], output)
        amf0.write_byte(header.get('mustUnderstand', False), output)
        content = StringIO()
        write_data(header['content'], content, context)
        amf0.write_long(len(content.getvalue()), output) # Length in bytes of header
        output.write(content.getvalue())
        content.close()
Exemplo n.º 2
0
def _write_bodies(bodies, output):
    body_count = len(bodies)
    amf0.write_int(body_count, output)
    for body in bodies:
        context = amf.AMFMessageBodyContext()
        amf0.write_utf(body.target, output)
        if body.response is None or body.response == '':
            body.response = 'null'
        amf0.write_utf(body.response, output)

        content = StringIO()
        write_data(body.data, content, context)

        amf0.write_long(len(content.getvalue()), output) # Body length in bytes
        output.write(content.getvalue())
        content.close()