Comparing version 0.1.8 to 0.1.10
{ | ||
"name": "q-http", | ||
"version": "0.1.8", | ||
"version": "0.1.10", | ||
"description": "Q promise based HTTP client and server interface", | ||
@@ -9,3 +9,3 @@ "homepage": "http://github.com/kriskowal/q-http/", | ||
"mail": "kris@cixar.com", | ||
"web": "http://github.com/kriskowal/q-http/issues" | ||
"url": "http://github.com/kriskowal/q-http/issues" | ||
}, | ||
@@ -12,0 +12,0 @@ "licenses": [ |
@@ -207,2 +207,38 @@ | ||
exports.normalizeRequest = function (request) { | ||
if (typeof request === "string") { | ||
request = { | ||
url: request | ||
}; | ||
} | ||
if (request.url) { | ||
var url = URL.parse(request.url); | ||
request.host = url.hostname; | ||
request.port = url.port; | ||
request.ssl = url.protocol === "https:"; | ||
request.method = request.method || "GET"; | ||
request.path = (url.pathname || "") + (url.search || ""); | ||
request.headers = request.headers || {}; | ||
request.headers.host = url.hostname; // FIXME name consistency | ||
} | ||
return request; | ||
}; | ||
exports.normalizeResponse = function (response) { | ||
if (response === void 0) { | ||
return; | ||
} | ||
if (typeof response == "string") { | ||
response = [response]; | ||
} | ||
if (response.forEach) { | ||
response = { | ||
status: 200, | ||
headers: {}, | ||
body: response | ||
} | ||
} | ||
return response; | ||
}; | ||
/** | ||
@@ -218,17 +254,3 @@ * Issues an HTTP request. | ||
if (typeof request === "string") { | ||
request = { | ||
url: request | ||
}; | ||
} | ||
if (request.url) { | ||
var url = URL.parse(request.url); | ||
request.host = url.hostname; | ||
request.port = url.port; | ||
request.ssl = url.protocol === "https:"; | ||
request.method = request.method || "GET"; | ||
request.path = (url.pathname || "") + (url.search || ""); | ||
request.headers = request.headers || {}; | ||
request.headers.host = url.hostname; // FIXME name consistency | ||
} | ||
request = exports.normalizeRequest(request); | ||
@@ -238,2 +260,7 @@ var deferred = Q.defer(); | ||
var http = ssl ? HTTPS : HTTP; | ||
var headers = request.headers || {}; | ||
headers.host = headers.host || request.host; | ||
var _request = http.request({ | ||
@@ -244,3 +271,3 @@ "host": request.host, | ||
"method": request.method || "GET", | ||
"headers": request.headers || {} | ||
"headers": headers | ||
}, function (_response) { | ||
@@ -247,0 +274,0 @@ deferred.resolve(exports.ClientResponse(_response)); |
var Q = require("q"); | ||
var HTTP = require("q-http"); | ||
var HTTP = require("../q-http"); | ||
@@ -5,0 +5,0 @@ var request = { |
var Q = require("q"); | ||
var HTTP = require("q-http"); | ||
var HTTP = require("../q-http"); | ||
@@ -5,0 +5,0 @@ var request = { |
var Q = require("q"); | ||
var HTTP = require("q-http"); | ||
var HTTP = require("../q-http"); | ||
@@ -5,0 +5,0 @@ var request = { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
25402
515
1
96
0
4