minimal-request-promise
Advanced tools
Comparing version 1.2.1 to 1.3.0
/*global module, require, global */ | ||
var https = require('https'), | ||
http = require('http'), | ||
urlParser = require('url'), | ||
@@ -8,3 +9,8 @@ minimalRequestPromise = function (callOptions, PromiseImplementation) { | ||
return new Promise(function (resolve, reject) { | ||
var req = https.request(callOptions); | ||
var req; | ||
if (callOptions.port === 80 || callOptions.protocol === 'http:') { | ||
req = http.request(callOptions); | ||
} else { | ||
req = https.request(callOptions); | ||
} | ||
@@ -11,0 +17,0 @@ req.on('response', function (res) { |
{ | ||
"name": "minimal-request-promise", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "A+ Promise interface to Node.js HTTPS request, with no dependencies", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
/*global beforeEach, afterEach, describe, it, expect, require, jasmine */ | ||
var fakeRequest = require('fake-http-request'), | ||
underTest = require('../index'), | ||
https = require('https'); | ||
https = require('https'), | ||
http = require('http'); | ||
describe('Minimal Request Promise', function () { | ||
@@ -9,5 +10,7 @@ 'use strict'; | ||
fakeRequest.install(); | ||
fakeRequest.install('http'); | ||
}); | ||
afterEach(function () { | ||
fakeRequest.uninstall(); | ||
fakeRequest.uninstall('http'); | ||
}); | ||
@@ -46,2 +49,7 @@ it('sends the args to the underlying request object', function () { | ||
}); | ||
it('uses http for port 80 requests', function () { | ||
underTest({port: 80, body: 'XYZ'}); | ||
expect(http.request.calls.length).toBe(1); | ||
expect(https.request.calls.length).toBe(0); | ||
}); | ||
['GET', 'POST'].forEach(function (method) { | ||
@@ -95,2 +103,8 @@ describe(method + ' helper', function () { | ||
}); | ||
it('uses http for http protocol requests', function () { | ||
helper('http://npmjs.org').then(function () { | ||
expect(http.request.calls.length).toBe(1); | ||
expect(https.request.calls.length).toBe(0); | ||
}); | ||
}); | ||
it('passes the promise implementation to the request generator', function () { | ||
@@ -97,0 +111,0 @@ var FakeImplementation = function () { |
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
Network access
Supply chain riskThis module accesses the network.
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
12413
228
4