Skip to content

Commit

Permalink
add-jshint for lib/https.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jsdevel committed Jan 23, 2014
1 parent e51fd64 commit 1d44a1f
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 43 deletions.
20 changes: 20 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"bitwise":false,
"boss":true,
"expr":true,
"camelcase":false,
"curly":false,
"eqeqeq":true,
"freeze":true,
"immed":true,
"indent":2,
"latedef":"nofunc",
"laxbreak":true,
"laxcomma":true,
"newcap":true,
"noarg":true,
"node":true,
"strict": true,
"trailing":true,
"undef":true
}
85 changes: 44 additions & 41 deletions lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,54 @@
* MIT Licensed
*/

var url = require('url'),
req = require('request');
"use strict";

var url = require('url');
var req = require('request');

var VERSION = "0.2.0";

exports.request = function(rurl, data, callback, exheaders, exoptions) {
var curl = url.parse(rurl);
var secure = curl.protocol == 'https:';
var host = curl.hostname;
var port = parseInt(curl.port || (secure ? 443 : 80));
var path = [curl.pathname || '/', curl.search || '', curl.hash || ''].join('');
var method = data ? "POST" : "GET";
var headers = {
"User-Agent": "node-soap/" + VERSION,
"Accept" : "text/html,application/xhtml+xml,application/xml,text/xml;q=0.9,*/*;q=0.8",
"Accept-Encoding": "none",
"Accept-Charset": "utf-8",
"Connection": "close",
"Host" : host
};

if (typeof data == 'string') {
headers["Content-Length"] = Buffer.byteLength(data, 'utf8');;
headers["Content-Type"] = "application/x-www-form-urlencoded";
}
var curl = url.parse(rurl);
var secure = curl.protocol === 'https:';
var host = curl.hostname;
var port = parseInt(curl.port || (secure ? 443 : 80));
var path = [curl.pathname || '/', curl.search || '', curl.hash || ''].join('');
var method = data ? "POST" : "GET";
var headers = {
"User-Agent": "node-soap/" + VERSION,
"Accept" : "text/html,application/xhtml+xml,application/xml,text/xml;q=0.9,*/*;q=0.8",
"Accept-Encoding": "none",
"Accept-Charset": "utf-8",
"Connection": "close",
"Host" : host
};
var attr;

if (typeof data === 'string') {
headers["Content-Length"] = Buffer.byteLength(data, 'utf8');
headers["Content-Type"] = "application/x-www-form-urlencoded";
}

exheaders = exheaders || {};
for (var attr in exheaders) { headers[attr] = exheaders[attr]; }
exheaders = exheaders || {};
for (attr in exheaders) { headers[attr] = exheaders[attr]; }

var options = {
uri: curl,
method: method,
headers: headers
};
var options = {
uri: curl,
method: method,
headers: headers
};

exoptions = exoptions || {};
for (var attr in exoptions) { options[attr] = exoptions[attr]; }

var request = req(options, function (error, res, body) {
if (error) {
callback(error);
} else {
request.on('error', callback);
callback(null, res, body);
}
});
request.end(data);
}
exoptions = exoptions || {};
for (attr in exoptions) { options[attr] = exoptions[attr]; }

var request = req(options, function (error, res, body) {
if (error) {
callback(error);
} else {
request.on('error', callback);
callback(null, res, body);
}
});
request.end(data);
};
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"lib": "./lib"
},
"scripts": {
"test": "mocha -R spec -u exports test/*-test.js"
"mocha": "mocha -R spec -u exports test/*-test.js",
"jshint" : "jshint lib/http.js",
"test": "npm run-script jshint && npm run-script mocha"
},
"keywords": [
"soap"
Expand All @@ -31,6 +33,7 @@
}
],
"devDependencies": {
"mocha": "~1.17.0"
"mocha": "~1.17.0",
"jshint": "~2.4.2"
}
}

0 comments on commit 1d44a1f

Please sign in to comment.