Update Curl file structure.

This commit is contained in:
Miao Jiang 2013-02-19 17:30:16 +08:00
parent 1057195bf5
commit 2c414d1469
6 changed files with 41 additions and 99 deletions

View file

@ -5,9 +5,9 @@
__slice = [].slice;
try {
Curl = require(__dirname + '/../build/Release/node-curl').Curl;
Curl = require(__dirname + '/Curl');
} catch (e) {
Curl = require(__dirname + '/../build/default/node-curl').Curl;
Curl = require(__dirname + '/Curl');
}
CurlBuilder = (function() {
@ -69,12 +69,13 @@
this.setOptions({
URL: this.url
});
c.on_write = function(chunk) {
c.on('data', function(chunk) {
curl.log("receive " + chunk.length + " bytes");
c.chunks.push(chunk);
return length += chunk.length;
};
c.on_end = function() {
length += chunk.length;
return chunk.length;
});
c.on('end', function() {
var chunk, data, position, _i, _len, _ref5,
_this = this;
curl.log("receive succeeded.");
@ -97,15 +98,15 @@
return process.nextTick(function() {
return cb.call(curl, null, curl);
});
};
c.on_error = function(err) {
});
c.on('error', function(err) {
var _this = this;
curl.log("receive failed: " + err.message);
curl.running = false;
return process.nextTick(function() {
return cb.call(curl, err, null);
});
};
});
this.log('perform');
return c.perform();
};