Permalink
Browse files

Friendlier curl opts

  • Loading branch information...
1 parent b4a64a5 commit ec6a7653a24460db2a801d9f4627378066bbb0e0 @chriso chriso committed Jan 2, 2012
Showing with 18 additions and 1 deletion.
  1. +17 −0 index.js
  2. +1 −1 package.json
View
@@ -1,6 +1,16 @@
var child = require('child_process');
/**
+ * Make curl opts friendlier.
+ */
+
+var curl_map = {
+ retries: 'retry'
+ , timeout: 'max-time'
+ , redirects: 'max-redirs'
+};
+
+/**
* Make a request with cURL.
*
* @param {Object|String} options (optional) - sent as --<key> <value> to curl
@@ -31,6 +41,13 @@ module.exports = function (options, callback) {
options = { url: options };
}
+ for (var key in curl_map) {
+ if (typeof options[key] !== 'undefined') {
+ options[curl_map[key]] = options[key];
+ delete options[key];
+ }
+ }
+
var curl
, args = ['--silent', '--show-error', '--no-buffer']
, start = new Date
View
@@ -1,6 +1,6 @@
{ "name" : "curlrequest",
"description" : "A curl wrapper for node",
- "version" : "0.1.2",
+ "version" : "0.1.3",
"homepage" : "https://github.com/chriso/curlrequest",
"author" : "Chris O'Hara <cohara87@gmail.com>",
"main" : "index",

0 comments on commit ec6a765

Please sign in to comment.