Skip to content

Commit

Permalink
fix bug that may cause request hang up when multi http request occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyz committed Oct 19, 2011
1 parent 37db175 commit 703bf77
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions item_prices/server/shops.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@

var Iconv = require('iconv').Iconv;
var gbk_to_utf8_iconv = new Iconv('GBK', 'UTF-8//TRANSLIT//IGNORE');
var utf8_to_gbk_iconv = new Iconv('UTF-8', 'GBK//TRANSLIT//IGNORE');

console.log("shops ext");

var g2u = exports.g2u = function(body) {
var gbk_to_utf8_iconv = new Iconv('GBK', 'UTF-8//TRANSLIT//IGNORE');
var utf8_buffer = gbk_to_utf8_iconv.convert(body);
var strText = utf8_buffer.toString();
return strText;
}

var u2g = exports.u2g = function(body) {
var utf8_to_gbk_iconv = new Iconv('UTF-8', 'GBK//TRANSLIT//IGNORE');
var utf8_buffer = utf8_to_gbk_iconv.convert(body);
var strText = utf8_buffer.toString();
return strText;
Expand Down
4 changes: 4 additions & 0 deletions item_prices/server/test_getpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var shops = require('./shops');
function do_search() {
//var remoteurl= "http://s.etao.com/search?q=%C0%CB%B3%B1%D6%AE%E1%DB";
var remoteurl= "http://s.etao.com/search?q=%C0%CB%B3%B1%D6%AE%E1%DB";
console.log(remoteurl);
var request = require('request');
request({url:remoteurl}, function (error, response, body) {
if (!error && response.statusCode == 200) {
Expand All @@ -16,6 +17,9 @@ function do_search() {
console.log("failed to find any shops");
});
}
else {
console.log("error");
}
});
}

Expand Down
4 changes: 3 additions & 1 deletion visit_once/DEBUG
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ debug url:

http://www.taobao.com/sitemap.php?id=sitemap2&__tlabs-dev&__tlabs_feature_id=144&__tlabs_feature_mod=visit_once.js

http://visitonce.cnodejs.net/put?u=%E7%A9%BA%E6%97%A0&msg=&url=www.taobao.com

visitonce.cnodejs.net/put?u=空无&msg=&url=www.taobao.com

//visitonce.cnodejs.net/put?u=空无&msg=&url=www.taobao.com



0 comments on commit 703bf77

Please sign in to comment.