dojo / core

:rocket: Dojo 2 - language helpers and utilities.
http://dojo.io
Other
213 stars 58 forks source link

Node request handler is String-converting the raw response data #314

Closed jason0x43 closed 7 years ago

jason0x43 commented 7 years ago

Bug

In request/providers/node.ts, the raw request data in dataAsBuffer is being converted to a string with String(dataAsBuffer) before being stored in the response object. Since no explicit encoding is specified, this converts the data to a 'utf8' string. This causes problems when downloading binary data, and is also redundant since Response.text() does the same thing.

Package Version: beta1

Code

var request = require('@dojo/core/request').default;
var writeFileSync = require('fs').writeFileSync;

request('https://github.com/dojo/core/archive/v2.0.0-beta1.1.zip').then(function (response) {
    response.arrayBuffer().then(function (data) {
        console.log('got ' + data.length + ' bytes');
    });
});

Expected behavior:

The data length should be 156603.

Actual behavior:

The data length is 269749, and is not a valid zip file.

rorticus commented 7 years ago

This was actually fixed way back when w/ https://github.com/dojo/core/pull/315