문제

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:

  1. Base64 Encoding;

Server Side:

  1. URL Decoding; (It seems the URL encoding is automatically done somewhere in the APE)
  2. Base64 Decoding.

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top