Skip to content

Commit

Permalink
Use Buffer to load data in node, use gzip
Browse files Browse the repository at this point in the history
* http request incorrectly retrieved images using UTF8 encoding
* Now all http data requests from Node will use Buffer object
* Use gzip to download data if available
* Tested with CSV, JSON, and TopoJson - buffer is parsed correctly
  (there should be tests that catch this automatically)
  • Loading branch information
Yuri Astrakhan committed May 28, 2015
1 parent 2eefdb5 commit 9db9ed9
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 59 deletions.
6 changes: 4 additions & 2 deletions src/data/load.js
Expand Up @@ -102,11 +102,13 @@ vg.data.load = (function() {

function http(url, callback) {
vg.log('LOAD HTTP: ' + url);
var options = {url: url};
var options = {url: url, encoding: null};
if (vg.config.dataHeaders) {
options.headers = vg.config.dataHeaders;
}
var req = require('request')(options, function(error, response, body) {
var request = require('request');
request.gzip = true;
request(options, function(error, response, body) {
if (!error && response.statusCode === 200) {
callback(null, body);
} else {
Expand Down

0 comments on commit 9db9ed9

Please sign in to comment.