Skip to content
Browse files

Require iconv-lite only if needed.

  • Loading branch information...
1 parent 7e29ea6 commit b59b9d8e6e55ab571ab8a0dfa48a59bda255a1e3 @tomas committed Aug 22, 2012
Showing with 4 additions and 5 deletions.
  1. +4 −5 lib/needle.js
View
9 lib/needle.js
@@ -8,7 +8,6 @@
var fs = require('fs'),
http = require('http'),
https = require('https'),
- iconv = require('iconv-lite'),
url_parse = require('url').parse,
stringify = require('qs').stringify,
multipart = require('./multipart');
@@ -202,10 +201,10 @@ var Needle = {
parse_content_type: function(header){
if (!header || header == '') return {};
- var charset, split = header.split(';');
- try { charset = split[1].match(/charset=(.+)/)[1] } catch (e) { /* not found */ }
+ var charset, arr = header.split(';');
+ try { charset = arr[1].match(/charset=(.+)/)[1] } catch (e) { /* not found */ }
- return { type: split[0], charset: charset };
+ return { type: arr[0], charset: charset };
},
response_end: function(opts, response, body, callback){
@@ -219,7 +218,7 @@ var Needle = {
});
} else {
if (!opts.utf8 && opts.charset)
- body = iconv.decode(body, opts.charset);
+ body = require('iconv-lite').decode(body, opts.charset);
callback(null, response, body.toString());
}

0 comments on commit b59b9d8

Please sign in to comment.
Something went wrong with that request. Please try again.