Comparing version 0.1.7 to 0.1.8
{ | ||
"name": "q-http", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "Q promise based HTTP client and server interface", | ||
@@ -19,5 +19,8 @@ "homepage": "http://github.com/kriskowal/q-http/", | ||
"dependencies": { | ||
"q": "0.7.1", | ||
"q-io": "0.0.10" | ||
"q": "0.7.2", | ||
"q-io": "0.0.11" | ||
}, | ||
"devDependencies": { | ||
"test": "0.4.1" | ||
}, | ||
"repository": { | ||
@@ -24,0 +27,0 @@ "type": "git", |
@@ -23,18 +23,73 @@ | ||
var server = HTTP.Server(function () { | ||
return response; | ||
}); | ||
exports['test basic'] = function (ASSERT, done) { | ||
Q.when(server.listen(8080), function () { | ||
console.log("Listening on", server.port); | ||
return Q.when(HTTP.request(request), function (response) { | ||
return Q.when(response.body, function (body) { | ||
var done = body.forEach(function (chunk) { | ||
console.log(chunk.toString("utf-8")); | ||
var server = HTTP.Server(function () { | ||
return response; | ||
}); | ||
Q.when(server.listen(8080), function () { | ||
return Q.when(HTTP.request(request)) | ||
.then(function (response) { | ||
ASSERT.ok(!Q.isPromise(response.body), "body is not a promise") | ||
var acc = []; | ||
return response.body.forEach(function (chunk) { | ||
acc.push(chunk.toString("utf-8")); | ||
}).then(function () { | ||
ASSERT.equal(acc.join(""), "Hello, World!", "body is hello world"); | ||
}); | ||
Q.when(done, server.stop); | ||
}); | ||
}) | ||
}) | ||
.fin(server.stop) | ||
.fin(done) | ||
.fail(function (reason) { | ||
ASSERT.ok(false, reason); | ||
}) | ||
} | ||
var deferredResponse = { | ||
"status": 200, | ||
"headers": { | ||
"content-type": "text/plain; charset=utf-8" | ||
}, | ||
"body": { | ||
"forEach": function (write) { | ||
var deferred = Q.defer(); | ||
write("Hello, World!"); | ||
setTimeout(function () { | ||
deferred.resolve(); | ||
}, 100); | ||
return deferred.promise; | ||
} | ||
} | ||
}; | ||
exports['test deferred'] = function (ASSERT, done) { | ||
var server = HTTP.Server(function () { | ||
return deferredResponse; | ||
}); | ||
}) | ||
.end(); | ||
Q.when(server.listen(8080), function () { | ||
return Q.when(HTTP.request(request)) | ||
.then(function (response) { | ||
var acc = []; | ||
return response.body.forEach(function (chunk) { | ||
acc.push(chunk.toString("utf-8")); | ||
}).then(function () { | ||
ASSERT.equal(acc.join(""), "Hello, World!", "body is hello world"); | ||
}); | ||
}) | ||
}) | ||
.fin(server.stop) | ||
.fin(done) | ||
.fail(function (reason) { | ||
ASSERT.ok(false, reason); | ||
}) | ||
} | ||
if (module === require.main) { | ||
require("test").run(exports); | ||
} | ||
Sorry, the diff of this file is not supported yet
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
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
22143
493
0
1
11
+ Addedq@0.7.2(transitive)
+ Addedq-io@0.0.11(transitive)
- Removedq@0.7.1(transitive)
- Removedq-io@0.0.10(transitive)
Updatedq@0.7.2
Updatedq-io@0.0.11