[Twisted-Python] AMP WebSockets bridging
Tom Sheffler
tom.sheffler at gmail.com
Sat Jun 16 09:16:03 MDT 2012
>
> On Jun 15, 2012, at 10:13 AM, Laurens Van Houtven wrote:
>
> > Hi,
> >
> > I'm trying to get browsers to communicate with an AMP API.
>
> This is also what <https://launchpad.net/frack> is doing. I hope that it
> becomes a common enough practice that there's a library for it :).
>
> > The issue is that while AMP is inherently a binary protocol, WebSockets
> transfer text (well, that's a lie: there's a binary version, but it's even
> less widely supported than WebSockets themselves -- and SockJS doesn't
> support it at all, although it's on the roadmap). So, I need an
> alternative, preferably 7-bit, serialization for AMP boxes.
>
> Did you immediately discard the obvious solution of "base64 everything"? :)
I had success simply base64'ing binary data. And I believe encoding that
is safe for binary data, but I may be wrong.
Use this:
data = binascii.b2a_base64(bindata).strip()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20120616/408d9a32/attachment.html>
More information about the Twisted-Python
mailing list