abeisgreat/python-firebasin — pull request #14 by perkinslr (2014-06-17 23:27:21+00:00)
Title: Support for messages longer than 16kb

When a message is longer than 16,000 characters, it is split into segments. Before the first segment arrives, a message arrives which specifies how many segments are expected. The old code will json load this into an integer and pass it to _process in dataref.py, where it will die trying to use __getitem__ on the integer, (line 263 or thereabouts). The next message will be an incomplete json-encoded object, the first 16kb of it, which chokes on line 118 of connection.py, with a ValueError: Expecting object:.... This patch catches number-messages, storing the number. It then takes the next n messages and stores them, not attempting to json.loads them and process them until the final message arrives. I am assuming the firebase protocol will ensure the messages arrive in a suitable order, since I find no way to obtain ordering information from the messages themselves.