This code example is from the APE official website: http://www.ape-project.org/
var client = new APE.Client();
client.load();
client.core.join('testChannel');
client.request.send('foo', {ping: 'ho hey', fieldWidthBinaryDataOrSpecialCharacters: '+/'});
client.onRaw('bar', function(raw, pipe) {
console.log('echo : ' + raw.data.echo);
console.log('Receiving : ' + raw.data.hello);
});
When I receive the data at the server side, I found that the special characters +/
has been URL encoded (%2B%2F
).
Is APE always using GET? If we use POST, I think we can post any data including Binary data, right? But how to use POST in JSON?
My case is, even I don't use the Binary format, I have to use the Base64. But the standard Base64 uses +/
which is not URL safe. You might suggest using the URL safe version of Base64, but URLSafeBase64 is not standard and it might also create other problems.
Am I misunderstanding something?
Thanks.
Peter
I finally did two-step encoding:
The Client Side:
Server Side:
P.S.: If any one knows how to do it in a more efficient way of transferring binary data, please let me know, and I will re-mark your answer as the correct one.