Christian Fraß
[add] server:lib:node_modules
Christian Fraß commited 6e9c872 at 2021-03-08 23:52:07
var should = require('should'),
needle = require('./../'),
http = require('http'),
sinon = require('sinon'),
stream = require('stream'),
fs = require('fs'),
port = 11111,
server;
describe('with output option', function() {
var server, handler, file = '/tmp/foobar.out';
function send_request_cb(where, cb) {
var url = 'http://localhost:' + port + '/whatever.file';
return needle.get(url, { output: where }, cb);
}
function send_request_stream(where, cb) {
var url = 'http://localhost:' + port + '/whatever.file';
var stream = needle.get(url, { output: where });
stream.on('end', cb);
}
// this will only work in UNICES
function get_open_file_descriptors() {
var list = fs.readdirSync('/proc/self/fd');
return list.length;
}
var send_request = send_request_cb;
before(function(){
server = http.createServer(function(req, res) {
handler(req, res);
}).listen(port);
});
after(function() {
server.close();
})
beforeEach(function() {
try { fs.unlinkSync(file) } catch(e) { };
})
describe('and a 404 response', function() {
before(function() {
handler = function(req, res) {
res.writeHead(404, {'Content-Type': 'text/plain' });
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX