-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Apparently we have two ways how to encode a buffer value:
- Method/callback arguments are encoded as
{ '$type': 'base64', '$data': 'MjM=' }, see see serialization and deserialization in strong-remoting - Model properties are encoded as
{ type: 'Buffer', data: [50, 51] }, this is the behaviour of Node core'sBuffer.prototype.toJSON
I am proposing to unify this behaviour and use only one encoding format. I think we should go with the format used by Node core, to make it easy to parse our output using JSON.parse.
In order to simplify the upgrade process, and also to support users that prefer Base64 (it uses less bandwidth), we can introduce a new flag in remoting-metadata that will instruct the response serializer to use Base64 encoding. The parser should always detect and support both base64 and array forms.
Example configuration:
{
returns: { arg: 'data', type: 'Buffer', encoding: 'base64' }
}Subtasks:
- fix strong-remoting
- fix iOS SDK
@raymondfeng @ritch @superkhau @STRML @fabien thoughts?
/cc @hideya