Commit Graph

647 Commits

Author SHA1 Message Date
Damien Arrachequesne
8440a57f76 chore: bump engine.io-parser version
See also: https://github.com/socketio/engine.io-protocol#difference-between-v3-and-v4

Release: https://github.com/socketio/engine.io-parser/releases/tag/4.0.0
Diff: https://github.com/socketio/engine.io-parser/compare/2.2.0...4.0.0
2020-09-09 00:02:24 +02:00
Damien Arrachequesne
2f5c948abe fix(react-native): restrict the list of options for the WebSocket object
Only 'headers' and 'localAddress' options are supported by the
WebSocket implementation in React Native.

The following message was printed to the console:

> Unrecognized WebSocket connection option(s) `agent`, `perMessageDeflate`, `pfx`, `key`, `passphrase`, `cert`, `ca`, `ciphers`, `rejectUnauthorized`. Did you mean to put these under `headers`?

Reference: https://reactnative.dev/docs/network.html#websocket-support
2020-05-25 07:34:17 +02:00
Damien Arrachequesne
3f3a6f9914 fix: use globalThis polyfill instead of self/global (#634)
In order to fix the "self is not defined" issues in Android 8 and React
Native.

Fixes https://github.com/socketio/engine.io-client/issues/611, https://github.com/socketio/engine.io-client/issues/626
Closes https://github.com/socketio/engine.io-client/pull/627
2020-04-16 16:08:37 +02:00
Chris West (Faux)
27fa6949f3 refactor: remove indexof dependency
This is a polyfill for indexOf(), which we use literally everywhere else.
2020-04-16 10:06:44 +02:00
Damien Arrachequesne
7c7f1a9fe2 fix: properly assign options when creating the transport
The query attribute was overwritten, due to the order of arguments in
the assignment. The bug was introduced in the refactor (5f47a50).
2020-02-12 08:14:51 +01:00
Damien Arrachequesne
5f47a50ee5 refactor: refactor the handling of the options 2020-02-11 23:33:34 +01:00
Damien Arrachequesne
81d7171c6b feat: reverse the ping-pong mechanism
The ping packets will now be sent by the server, because the timers set
in the browsers are not reliable enough. We suspect that a lot of
timeout problems came from timers being delayed on the client-side.

Breaking change: v3.x clients will not be able to connect anymore (they
will send a ping packet and timeout while waiting for a pong packet).

Related: https://github.com/socketio/engine.io/issues/312
2020-02-04 12:29:37 +01:00
Damien Arrachequesne
08aff9487f refactor: use prettier to format code 2020-01-14 22:58:35 +01:00
Damien Arrachequesne
0fcc5417ac refactor: migrate to ES6 syntax 2020-01-10 07:29:26 +01:00
Damien Arrachequesne
11dc4f3a56 chore: migrate to webpack 4
Breaking change: the output bundle will now be found in the dist/ folder.
2020-01-10 07:27:02 +01:00
Christopher
fd7fff252d [fix] Ensure valid status is passed to error handler (#622)
Closes https://github.com/socketio/engine.io-client/issues/621
2019-09-13 11:59:51 +02:00
Nubami SQReder
226626921d [feat] Support extra charset info in Content-Type header (#619)
XHR Polling failed to make handshake with server that adds charset info into Content-Type header.

Closes https://github.com/socketio/engine.io-client/issues/618
2019-09-13 11:58:24 +02:00
Jake Barnes
2847411dd0 [feat] Add withCredentials option (#614)
withCredentials was always set to true, despite the browser default being false, and can now be overridden.

Closes https://github.com/socketio/engine.io-client/issues/495
2019-09-13 11:56:36 +02:00
Szymon Lesisz
0eeaa7a927 [fix] fix NodeWebSocket declaration (#613)
NodeWebSocket was be required ONLY if global variables self and WebSocket were not defined.

Closes https://github.com/socketio/engine.io-client/issues/609
2019-09-13 11:53:59 +02:00
Ben James
1ec53d424d [fix] Fix Websocket implementation in React Native (#607)
As `self` is undefined in React Native.
2019-01-20 22:34:30 +01:00
Damien Arrachequesne
66b9e4a186 [fix] fix JSONP transport in Node.js environment
The commit 99bcc62 resulted in `window is not defined` errors.
2018-11-19 22:12:20 +01:00
Nubami SQReder
f62fca4b05 [fix] Trigger xhr polling transport unload handler on 'pagehide' or 'unload' instead of 'beforeunload' (#604)
...to prevent broke connection on cancelled beforeunload event

Fixes #603
2018-11-19 13:11:45 +01:00
Damien Arrachequesne
99bcc622cb [fix] Remove any reference to the global variable
Related: https://github.com/socketio/socket.io-client/issues/1166
2018-11-07 22:40:39 +01:00
Craig Thayer
26e9329050 [feat] Detect React-Native environment and use all websocket features (#591)
React-Native provides a Websocket object that is more functionally aligned with the Node.js websocket than the browser websocket.

It has the same constructor signature as the Node.js websocket and can support extraHeaders and protocols.

This PR will detect when the engine.io-client is running in React-Native, call the proper Websocket constructor, and enable support for extraHeaders.
2018-11-02 08:09:02 +01:00
Thomas Hunkapiller
4349b648d4 [fix] Fix UTF-8 encoding in Firefox WebWorker (#596) 2018-03-09 13:01:02 +01:00
Damien Arrachequesne
8cde767f94 [test] Update travis configuration (#594) 2018-02-28 01:02:49 +01:00
Damien Arrachequesne
64ce48046f fix: use try/catch when setting xhr.responseType (#592)
Some XHR implementations (like Firefox WebWorker, react-native and some Android 4.x versions) throw
an exception when setting xhr.responseType = 'arraybuffer' when xhr.readyState === 2 (which is
perfectly valid, spec-wise).

That commit fixes that behaviour by reverting some of the changes from
https://github.com/socketio/engine.io-client/pull/562 for those implementations.

Fixes #589
Closes #590
2018-02-18 11:35:00 +01:00
Damien Arrachequesne
42501c658e [revert] [refactor] Remove usuless indexof dependency (#582)
This reverts commit 6043c49e91.
2017-10-11 07:33:55 +02:00
Damien Arrachequesne
6043c49e91 [refactor] Remove usuless indexof dependency (#582) 2017-10-08 10:00:09 +02:00
Matt Grande
0b26bc3fd8 [fix] Remove parsejson dependency (#580)
Related: https://nodesecurity.io/advisories/528.
2017-09-27 22:33:04 +02:00
Damien Arrachequesne
7aad0d6da1 [chore] Bump engine.io-parser to version 2.1.0 (#565) 2017-04-24 23:50:37 +02:00
Tom Atkinson
3e0334645b [refactor] Set responseType based on 'Content-Type' header (#562) 2017-04-24 13:04:26 +02:00
Damien Arrachequesne
beb7090318 [fix] Default rejectUnauthorized to true (#558) 2017-03-24 13:00:58 +01:00
Damien Arrachequesne
56bf176bc6 [chore] Bump engine.io-parser to version 2.0.2 (#555) 2017-03-22 07:24:53 +01:00
stormbkk87
151976594e [feat] Allow to set the protocols for the websocket transport (#546)
Some WebSocket implementations require the protocols parameter or will
fail connection.
2017-03-06 13:07:19 +01:00
Denis Yaremov
22c28a24b7 [fix] Fix extraHeaders option in browser (#536) 2017-02-01 14:46:07 +01:00
Damien Arrachequesne
b1baf8d998 [feature] Allow extraHeaders to be set for browser clients in XHR requests (#519) 2016-12-30 17:08:38 +01:00
Damien Arrachequesne
c01b9a8560 [feature] Add support for per transport options (#518) 2016-12-30 16:46:36 +01:00
magicdawn@qq.com
9cfc626bf7 [feature] add localAddress option (#487) 2016-10-31 01:34:19 +01:00
Daniel Schlosser
8be5864169 [feature] Added flag forceNode to override the normal behavior of prefering Browser based implementations. (#469) 2016-10-30 23:49:55 +01:00
Ben Ripkens
3427e744e1 Enable definition of timeouts for xhr-polling
The definition of timeouts is desirable to cancel long outstanding
requests automatically via browser mechanisms. Specifically, it can
happen that lots of pending XHR requests are scheduled, but are never
purged by the browser due to the lack of a timeout definition.
2016-10-30 22:06:00 +01:00
Jarmo Isotalo
a38551f45f Fixed regression creating connection over wss from node 2016-10-28 04:14:52 +03:00
Jarmo Isotalo
9abcb152da Fixed regression creating connection over https from node 2016-10-28 02:58:42 +03:00
Luigi Pinca
7acae3db15 [fix] Obfuscate ActiveXObject occurrences (#509)
Some corporate firewalls/proxies such as Blue Coat prevent JavaScript
files from being downloaded if they contain the word "ActiveX".
2016-10-24 01:00:45 +02:00
besaplla
618758543e [fix] onPacket now emits data on 'closing' state as well (#484) 2016-10-23 09:15:11 +02:00
Naoyuki Kanezawa
410189e417 [fix] remove a workaround for ios (#465) 2016-10-23 08:44:35 +02:00
Tom Atkinson
083a139488 [fix] Set accept header to */* to support react app proxy (#508) 2016-10-23 08:43:52 +02:00
Tom Atkinson
b18f5b16df [perf] Add all properties to the socket in the constructor (#488) 2016-10-20 18:29:32 +02:00
Marshall Thompson
6b2b3bdaaa [chore] Use more-specific imports for StealJS compatibility (#467)
This allows browser loaders like StealJS to load this package without showing any errors or warnings in the console (since you the only way to check if a file exists from the browser it to request it, node-style folder assumptions can't be made without potential 404s.)

The package works fine with the StealJS build tools, since they're node based, but this lets allows it to work with the browser version.
2016-10-20 18:10:30 +02:00
Aaron Carlino
eb24245565 [fix] Define "requestsCount" var and "requests" hash unconditionally (#490)
There are situations in which `global.document` can be defined after the file is loaded, but before a request is created.
2016-10-20 17:55:05 +02:00
Damien Arrachequesne
aa48d134d4 [style] Add missing semi-colon (#501) 2016-10-05 10:29:43 +02:00
Mateusz Burzyński
f9274e181e [fix] Fix issue with errors during WebSocket creation not being caught at all (#475)
Fixes #474.
2016-10-05 07:35:30 +02:00
Miguel Grinberg
ea29487488 [fix] Use xhr.responseText if xhr.response is not provided (#483) 2016-10-05 07:31:28 +02:00
Damien Arrachequesne
67ac4b7e1d Revert "default rejectUnauthorized to true" (#496)
This reverts commit 2c55b278a4, which breaks websocket transport under node v0.10 (#494).
2016-10-05 07:06:38 +02:00
Doug Wade
22ec2d2b97 Fix test target by specifying valid ws binary type 2016-06-29 11:27:05 -07:00