diff --git a/lib/CurlBuilder.js b/lib/CurlBuilder.js index eae337f..30a3a07 100644 --- a/lib/CurlBuilder.js +++ b/lib/CurlBuilder.js @@ -39,7 +39,7 @@ var args, c, cb, k, length, v, _ref, _ref1, _ref2, _ref3, _ref4; args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; if (this.running) { - throw new Error('the cURL session is busy, use CurlBuilder.create to create another cURL Session'); + throw new Error('the cURL session is busy, use curl.create to create another cURL Session'); } if (!this.curl_) { throw new Error('the cURL is closed.'); @@ -54,19 +54,21 @@ c.chunks = []; length = 0; this.debug = (_ref1 = (_ref2 = this.defaultOptions.DEBUG) != null ? _ref2 : this.options.DEBUG) != null ? _ref1 : this.debug; - this.effective_options = {}; + this.effectiveOptions = {}; _ref3 = this.defaultOptions; for (k in _ref3) { v = _ref3[k]; - this.effective_options[k] = v; + this.effectiveOptions[k] = v; } _ref4 = this.options; for (k in _ref4) { v = _ref4[k]; - this.effective_options[k] = v; + this.effectiveOptions[k] = v; } - this.setOptions(this.effective_options); - this.curl_.setopt('URL', this.url); + this.setOptions(this.effectiveOptions); + this.setOptions({ + URL: this.url + }); c.on_write = function(chunk) { curl.log("receive " + chunk.length + " bytes"); c.chunks.push(chunk); @@ -114,7 +116,7 @@ if (reset == null) { reset = true; } - this.defaultOptions = options; + defaultOptions = options; if (reset) { this.log('Set default options and reset cURL'); return this.reset(); diff --git a/lib/CurlBuilder.toffee b/lib/CurlBuilder.toffee index 0cbdfc2..54d1ebe 100644 --- a/lib/CurlBuilder.toffee +++ b/lib/CurlBuilder.toffee @@ -18,7 +18,7 @@ class CurlBuilder curl.perform = (args...) -> if @running - throw new Error 'the cURL session is busy, use CurlBuilder.create to create another cURL Session' + throw new Error 'the cURL session is busy, use curl.create to create another cURL Session' if !@curl_ throw new Error 'the cURL is closed.' @@ -37,15 +37,15 @@ class CurlBuilder @debug = @defaultOptions.DEBUG ? @options.DEBUG ? @debug - @effective_options = {} + @effectiveOptions = {} for k, v of @defaultOptions - @effective_options[k] = v + @effectiveOptions[k] = v + for k, v of @options - @effective_options[k] = v + @effectiveOptions[k] = v - @setOptions @effective_options - - @curl_.setopt('URL', @url) + @setOptions @effectiveOptions + @setOptions {URL: @url} c.on_write = (chunk) -> curl.log "receive #{chunk.length} bytes" @@ -84,7 +84,7 @@ class CurlBuilder curl.setDefaultOptions = (options = {}, reset = true) -> - @defaultOptions = options + defaultOptions = options if reset @log 'Set default options and reset cURL' @reset()