Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handshake failed when backend add charset into Content-Type header #618

Closed
1 of 2 tasks
SQReder opened this issue Aug 16, 2019 · 0 comments
Closed
1 of 2 tasks

Handshake failed when backend add charset into Content-Type header #618

SQReder opened this issue Aug 16, 2019 · 0 comments

Comments

@SQReder
Copy link
Contributor

SQReder commented Aug 16, 2019

Note: for support questions, please use one of these channels: stackoverflow or slack

You want to:

  • report a bug
  • request a feature

Current behaviour

Undertow server forcibly add charset into Content-Type header, so response type not recognized as arrayboffer and connection fails with parser error message.

Steps to reproduce (if the current behaviour is a bug)

  1. Server respond with normal handshake, with Content-Type: application/octet-stream; charset=UTF-8
  2. Connection establishing fails

Expected behaviour

Connection succeed

Setup

  • OS: Win 10
  • browser: Chrome 70+
  • engine.io version: 3.3.1

Other information (e.g. stacktraces, related issues, suggestions how to fix)

Naive fix is extend checks of content type

Index: lib/transports/polling-xhr.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- lib/transports/polling-xhr.js	(revision 57f9d457d593429cd66c6f1e1909835ac1fce456)
+++ lib/transports/polling-xhr.js	(date 1565959739511)
@@ -243,7 +243,7 @@
         if (xhr.readyState === 2) {
           try {
             var contentType = xhr.getResponseHeader('Content-Type');
-            if (self.supportsBinary && contentType === 'application/octet-stream') {
+            if (self.supportsBinary && contentType === 'application/octet-stream' || contentType === 'application/octet-stream; charset=UTF-8') {
               xhr.responseType = 'arraybuffer';
             }
           } catch (e) {}
@@ -355,7 +355,7 @@
     try {
       contentType = this.xhr.getResponseHeader('Content-Type');
     } catch (e) {}
-    if (contentType === 'application/octet-stream') {
+    if (contentType === 'application/octet-stream' || contentType === 'application/octet-stream; charset=UTF-8') {
       data = this.xhr.response || this.xhr.responseText;
     } else {
       data = this.xhr.responseText;
enderson-pan pushed a commit to holytiny/feathersjs-wxmp-socket.io-client that referenced this issue Nov 1, 2019
XHR Polling failed to make handshake with server that adds charset info into Content-Type header.

Closes socketio/engine.io-client#618
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant