Skip to content

Commit 44c7aa5

Browse files
author
Tony Kovanen
committed
Fix parse error
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.
1 parent b8ec539 commit 44c7aa5

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

lib/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*/
44

55
var utf8 = require('utf8');
6-
var hasBinary = require('has-binary');
76
var after = require('after');
87
var keys = require('./keys');
98

@@ -227,7 +226,7 @@ exports.encodePayload = function (packets, supportsBinary, callback) {
227226
supportsBinary = null;
228227
}
229228

230-
if (supportsBinary && hasBinary(packets)) {
229+
if (supportsBinary) {
231230
return exports.encodePayloadAsBinary(packets, callback);
232231
}
233232

test/browser/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,21 @@ if (Blob) {
99
}
1010

1111
require('./base64_object.js');
12+
13+
// General browser only tests
14+
var parser = require('../../');
15+
var encode = parser.encodePacket;
16+
var decode = parser.decodePacket;
17+
var encPayload = parser.encodePayload;
18+
var decPayload = parser.decodePayload;
19+
20+
describe('basic functionality', function () {
21+
it('should encode string payloads as strings even if binary supported', function (done) {
22+
encPayload([{ type: 'ping' }, { type: 'post' }], true, function(data) {
23+
expect(data).to.be.a('string');
24+
done();
25+
});
26+
});
27+
});
28+
29+

test/parser.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,6 @@ module.exports = function(parser) {
153153
});
154154
});
155155

156-
describe('basic functionality', function () {
157-
it('should encode string payloads as strings even if binary supported', function (done) {
158-
encPayload([{ type: 'ping' }, { type: 'post' }], true, function(data) {
159-
expect(data).to.be.a('string');
160-
done();
161-
});
162-
});
163-
});
164-
165156
describe('encoding and decoding', function () {
166157
var seen = 0;
167158
it('should encode/decode packets', function (done) {

0 commit comments

Comments
 (0)