Skip to content

Commit

Permalink
Fix parse error
Browse files Browse the repository at this point in the history
We always need to send binary when encoding payloads when sending from
server to client, because the polling transport has to know the response
type ahead of time.
  • Loading branch information
Tony Kovanen committed Jan 16, 2015
1 parent b8ec539 commit 44c7aa5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
3 changes: 1 addition & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/

var utf8 = require('utf8');
var hasBinary = require('has-binary');
var after = require('after');
var keys = require('./keys');

Expand Down Expand Up @@ -227,7 +226,7 @@ exports.encodePayload = function (packets, supportsBinary, callback) {
supportsBinary = null;
}

if (supportsBinary && hasBinary(packets)) {
if (supportsBinary) {
return exports.encodePayloadAsBinary(packets, callback);
}

Expand Down
18 changes: 18 additions & 0 deletions test/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,21 @@ if (Blob) {
}

require('./base64_object.js');

// General browser only tests
var parser = require('../../');
var encode = parser.encodePacket;
var decode = parser.decodePacket;
var encPayload = parser.encodePayload;
var decPayload = parser.decodePayload;

describe('basic functionality', function () {
it('should encode string payloads as strings even if binary supported', function (done) {
encPayload([{ type: 'ping' }, { type: 'post' }], true, function(data) {
expect(data).to.be.a('string');
done();
});
});
});


9 changes: 0 additions & 9 deletions test/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,6 @@ module.exports = function(parser) {
});
});

describe('basic functionality', function () {
it('should encode string payloads as strings even if binary supported', function (done) {
encPayload([{ type: 'ping' }, { type: 'post' }], true, function(data) {
expect(data).to.be.a('string');
done();
});
});
});

describe('encoding and decoding', function () {
var seen = 0;
it('should encode/decode packets', function (done) {
Expand Down

0 comments on commit 44c7aa5

Please # to comment.