node-curl/lib/curl.js
jiangfriend@gmail.com 90f3135c8c fixes #2 CookieList returning same data for each cookie
new structure for node-curl
2012-05-28 19:55:17 +08:00

79 lines
2.2 KiB
JavaScript

// Generated by ToffeeScript 1.3.3
(function() {
var Curl, CurlBuilder, curl;
try {
Curl = require(__dirname + '/../build/Release/node-curl').Curl;
} catch (e) {
Curl = require(__dirname + '/../build/default/node-curl').Curl;
}
CurlBuilder = require(__dirname + '/CurlBuilder');
Curl.prototype.setopt_user_ = function(option_id, value) {
return this.options[option_id] = value;
};
Curl.prototype.setopt = function(ooption, value) {
var option, option_id;
option = ooption.toUpperCase();
if ((option_id = Curl.user_options[option]) != null) {
return this.setopt_user_(option_id, value);
} else if ((option_id = Curl.slist_options[option]) != null) {
return this.setopt_slist_(option_id, value);
} else if ((option_id = Curl.integer_options[option]) != null) {
return this.setopt_int_(option_id, value >> 0);
} else if ((option_id = Curl.string_options[option]) != null) {
return this.setopt_str_(option_id, value.toString());
} else {
throw new Error("unsupported option " + option);
}
};
Curl.prototype.getinfo = function(oinfo) {
var info, info_id;
info = oinfo.toUpperCase();
if ((info_id = Curl.slist_infos[info]) != null) {
return this.getinfo_slist_(info_id);
} else if ((info_id = Curl.integer_infos[info]) != null) {
return this.getinfo_int_(info_id);
} else if ((info_id = Curl.string_infos[info]) != null) {
return this.getinfo_str_(info_id);
} else if ((info_id = Curl.double_infos[info]) != null) {
return this.getinfo_double_(info_id);
} else {
throw new Error("unsupported info " + oinfo);
}
};
Curl.user_options = {
RAW: 'RAW'
};
Curl.prototype.perform = function() {
this.perform_();
return Curl.process();
};
Curl.process = function() {
var once;
if (Curl.in_process) {
return;
}
return (once = function() {
var num;
num = Curl.process_();
if (num > 0) {
Curl.in_process = true;
return setTimeout(once, 80);
} else {
return Curl.in_process = false;
}
})();
};
curl = CurlBuilder.create();
module.exports = curl;
}).call(this);