From 441b622709402ebc6677f1f2c9837c8a43e79b63 Mon Sep 17 00:00:00 2001 From: Karim DRIDI Date: Thu, 29 Nov 2012 00:36:54 +0100 Subject: [PATCH] Minor bug: Segmentation fault on getinfo for a unfilled value --- examples/quick-start.js | 19 ++++++++++++++----- src/node-curl.h | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/examples/quick-start.js b/examples/quick-start.js index da7f4ba..24b37d2 100644 --- a/examples/quick-start.js +++ b/examples/quick-start.js @@ -1,23 +1,32 @@ Curl = require('../index'); options = {CONNECTTIMEOUT: 2}; +keys = ["EFFECTIVE_URL", "CONTENT_TYPE", "PRIVATE", "FTP_ENTRY_PATH", "REDIRECT_URL", "PRIMARY_IP", "RTSP_SESSION_ID", "LOCAL_IP"] curl = Curl.create(options) url = 'www.nodejs.org'; curl(url, function(err) { - console.info("\x1b[33meffetcive url: " + this.info('EFFECTIVE_URL') + "\x1b[0m"); + self = this + keys.forEach(function(key) { + console.info("\x1b[33m" + key + ": [" + self.info(key) + "]\x1b[0m"); + }) console.info("body length: " + this.body.length); this.close() }); - curl = Curl.create(options) url = 'www.yahoo.com' curl(url, function(err) { - console.info("\x1b[33meffetcive url: " + this.info('EFFECTIVE_URL') + "\x1b[0m"); + self = this + keys.forEach(function(key) { + console.info("\x1b[33m" + key + ": [" + self.info(key) + "]\x1b[0m"); + }) console.info("body length: " + this.body.length); this.close() }); - curl = Curl.create(options) curl('https://www.google.com', {VERBOSE: 1, RAW: 1}, function(err) { - console.info("\x1b[33meffetcive url: " + this.info('EFFECTIVE_URL') + "\x1b[0m"); + self = this + keys.forEach(function(key) { + console.info("\x1b[33m" + key + ": [" + self.info(key) + "]\x1b[0m"); + }) + console.info("body length: " + this.body.length); this.close() }); diff --git a/src/node-curl.h b/src/node-curl.h index 39c18f8..92cf14b 100644 --- a/src/node-curl.h +++ b/src/node-curl.h @@ -155,7 +155,7 @@ class NodeCurl { return raise("curl_easy_getinfo failed", curl_easy_strerror(code)); } - return JsClass::New(result); + return result ? JsClass::New(result) : v8::Null(); } static v8::Handle getinfo_int(const v8::Arguments & args)