rauchg/node.dbslayer.js

Response does not support UTF8

Opened this issue · 0 comments

DBSlayer returns its responses in UTF8 format. At present node.dbslayer does not properly set the body encoding when retrieving responses from dbslayer. As such any non-ascii characters in the response data will be corrupted by node.dbslayer. To fix this, change:

request.finish(function(response){
        response.addListener('body', function(data){  
            try {
                var object = JSON.parse(data);

to

request.finish(function(response){
        response.setBodyEncoding("utf8");
        response.addListener('body', function(data){  
            try {
                var object = JSON.parse(data);

The key is the second line of the new version, response.setBodyEncoding("utf8").