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

xmlhttprequest does not support binary data response in node #408

Closed
stevedw opened this issue Aug 8, 2015 · 1 comment
Closed

xmlhttprequest does not support binary data response in node #408

stevedw opened this issue Aug 8, 2015 · 1 comment

Comments

@stevedw
Copy link

stevedw commented Aug 8, 2015

When using engine.io-client in node application/octet responses are ignored by the client as xmlhttprequest does not support the response field.

e.g
// line 465 on xmlhttprequest

 response.on('data', function(chunk) {
          // Make sure there's some data
          if (chunk) {
            self.responseText += chunk;
          }
          // Don't emit state changes if the connection has been aborted.
          if (sendFlag) {
            setState(self.LOADING);
          }
        });

the polling xhr transport is only looking for xhr.response which is never set:
//polling-xhr.js

Request.prototype.onLoad = function(){
  var data;
  try {
    var contentType;
    try {
      contentType = this.xhr.getResponseHeader('Content-Type').split(';')[0];
    } catch (e) {}
   if (contentType === 'application/octet-stream') {
      data = this.xhr.response;
    } else {
      if (!this.supportsBinary) {
        data = this.xhr.responseText;
      } else {
        data = 'ok';
      }
    }
  } catch (e) {
    this.onError(e);
  }
  if (null != data) {
    this.onData(data);
  }
};

The data object is there always null on the response.
Would you consider moving to something like xhr2 instead as this does support binary payloads?

@nkzawa nkzawa added the Bug label Jan 16, 2016
@darrachequesne
Copy link
Member

Closed by #483, thanks for the report.

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

3 participants