Exemplo n.º 1
0
def write_envelope(version, filename):
    envelope = Envelope(amfVersion=version)
    message = Response(records)
    envelope.__setitem__('message', message);
    stream = remoting.encode(envelope)
    file = open(filename, 'w+')
    file.write(stream.getvalue())
Exemplo n.º 2
0
def write_envelope(version, filename):
    envelope = Envelope(amfVersion=version)
    message = Response(records)
    envelope.__setitem__('message', message)
    stream = remoting.encode(envelope)
    file = open(filename, 'w+')
    file.write(stream.getvalue())
Exemplo n.º 3
0
    def test_amf_parse(self):
        mq = MethodQueryCanonicalizer("POST", "application/x-amf", 0, BytesIO())

        req = Request(target="t", body="")
        ev_1 = Envelope(AMF3)
        ev_1["/0"] = req

        req = Request(target="t", body="alt_content")
        ev_2 = Envelope(AMF3)
        ev_2["/0"] = req

        assert amf_parse(encode(ev_1).getvalue()) != amf_parse(encode(ev_2).getvalue())
Exemplo n.º 4
0
    def test_amf_parse(self):
        mq = MethodQueryCanonicalizer('POST', 'application/x-amf', 0, BytesIO())

        req = Request(target='t', body="")
        ev_1 = Envelope(AMF3)
        ev_1['/0'] = req

        req = Request(target='t', body="alt_content")
        ev_2 = Envelope(AMF3)
        ev_2['/0'] = req

        assert mq.amf_parse(encode(ev_1).getvalue(), None) != \
               mq.amf_parse(encode(ev_2).getvalue(), None)
pyamf.register_class(Foo, 'Foo');

foo = Foo()
foo.bar = 'baz'

# create an associative array (ECMA Array)
ecmaArray = pyamf.MixedArray({
    'a': 'b',
    'c': 'd',
})

#-----------------------------------------------
# AMF0 all data types
#-----------------------------------------------

envelope = Envelope(amfVersion=0)

message0 = Response({
    'integer': 42,
    'dbl': 90.01,
    'tru': True,
    'fls': False,
    'str': 'sencha',
    'obj': { 'a': 1, 'b': 2 },
    'none': None,
    'undef': pyamf.Undefined,
    'ecmaArray': pyamf.MixedArray(a='1', b='2', c='3'),
    'strictArray': [ 1, 2, 3 ],
    'date': datetime.date(2012, 12, 31),
    'xmlDocument': xmlDocument,
    'typedObject': foo,
Exemplo n.º 6
0
def generate_amf_request(request_body=None):
    req = Request(target='UserService', body=request_body)
    ev = Envelope(pyamf.AMF3)
    ev['/0'] = req

    return encode(ev).getvalue()
Exemplo n.º 7
0
pyamf.register_class(Foo, 'Foo')

foo = Foo()
foo.bar = 'baz'

# create an associative array (ECMA Array)
ecmaArray = pyamf.MixedArray({
    'a': 'b',
    'c': 'd',
})

#-----------------------------------------------
# AMF0 all data types
#-----------------------------------------------

envelope = Envelope(amfVersion=0)

message0 = Response({
    'integer': 42,
    'dbl': 90.01,
    'tru': True,
    'fls': False,
    'str': 'sencha',
    'obj': {
        'a': 1,
        'b': 2
    },
    'none': None,
    'undef': pyamf.Undefined,
    'ecmaArray': pyamf.MixedArray(a='1', b='2', c='3'),
    'strictArray': [1, 2, 3],