lib/curl.js
function(uri, method, headers, data, encType) {
    var config = this.config;
    var flags = [];
    var str;

    method = method || 'GET';

    if (data && method.toLowerCase() === 'get') {
      uri += this.buildQueryString(data);
    }

    str = ['curl', this.buildFlag('X', method.toUpperCase(), 0, ''), '"' + uri + '"'].join(' ');

    if (headers) {
      _.each(headers, function(val, header) {
        flags.push(this.buildFlag('H', header + config.HEADER_SEPARATOR + val, 5));
      }, this);
    }

    if (data && method.toLowerCase() !== 'get') {
      if (encType === undefined || encType.match(this.formatter.jsonMediaType)) {
        flags.push(this.buildFlag('-data', this.formatData(data), 5, '\''));
      } else if (encType === 'multipart/form-data') {
        flags.push(this.buildFlag('-form', this.formatForm(data), 5, '"'));
      } else {
        // The non-JSON, non-multipart data is a raw string.  Do not format it.
        flags.push(this.buildFlag('-data', data));
      }
    }

    if (flags.length) {
      return str + config.NEW_LINE + flags.join(config.NEW_LINE);
    }
    return str;
  }
function(uri, method, headers, data, encType) {
    var config = this.config;
    var flags = [];
    var str;

    method = method || 'GET';

    if (data && method.toLowerCase() === 'get') {
      uri += this.buildQueryString(data);
    }

    str = ['curl', this.buildFlag('X', method.toUpperCase(), 0, ''), '"' + uri + '"'].join(' ');

    if (headers) {
      _.each(headers, function(val, header) {
        flags.push(this.buildFlag('H', header + config.HEADER_SEPARATOR + val, 5));
      }, this);
    }

    if (data && method.toLowerCase() !== 'get') {
      if (encType === undefined || encType.match(this.formatter.jsonMediaType)) {
        flags.push(this.buildFlag('-data', this.formatData(data), 5, '\''));
      } else if (encType === 'multipart/form-data') {
        flags.push(this.buildFlag('-form', this.formatForm(data), 5, '"'));
      } else {
        // The non-JSON, non-multipart data is a raw string.  Do not format it.
        flags.push(this.buildFlag('-data', data));
      }
    }

    if (flags.length) {
      return str + config.NEW_LINE + flags.join(config.NEW_LINE);
    }
    return str;
  }
function ( uri , method , headers , data , encType ) { var config = this . config ; var flags = [ ] ; var str ; method = method || 'GET' ; if ( data && method . toLowerCase ( ) === 'get' ) { uri += this . buildQueryString ( data ) ; } str = [ 'curl' , this . buildFlag ( 'X' , method . toUpperCase ( ) , 0 , '' ) , '"' + uri + '"' ] . join ( ' ' ) ; if ( headers ) { _ . each ( headers , function ( val , header ) { flags . push ( this . buildFlag ( 'H' , header + config . HEADER_SEPARATOR + val , 5 ) ) ; } , this ) ; } if ( data && method . toLowerCase ( ) !== 'get' ) { if ( encType === undefined || encType . match ( this . formatter . jsonMediaType ) ) { flags . push ( this . buildFlag ( '-data' , this . formatData ( data ) , 5 , '\'' ) ) ; } else if ( encType === 'multipart/form-data' ) { flags . push ( this . buildFlag ( '-form' , this . formatForm ( data ) , 5 , '"' ) ) ; } else { // The non-JSON, non-multipart data is a raw string.  Do not format it. flags . push ( this . buildFlag ( '-data' , data ) ) ; } } if ( flags . length ) { return str + config . NEW_LINE + flags . join ( config . NEW_LINE ) ; } return str ; }
Build a cURL string

@param {String} uri
@param {String} [method=GET]
@param {Object} [headers]
@param {Object|Array} [data]
@param {String} [encType=undefined]
@returns {String}
Build a cURL string