mirror of
https://github.com/ariya/phantomjs.git
synced 2024-08-15 15:50:34 +03:00
modernizr.js is not modified because it's not our code. En passant fixes: * Delete two scripts that depended on a Yahoo service that appears no longer to exist. * The PhantomJS website no longer has a leading www. * One script needed correction to *work* in strict mode. * One script would only exit if a page loaded successfully. (There may be other instances of this problem, this is the one I noticed.)
36 lines
1.0 KiB
JavaScript
36 lines
1.0 KiB
JavaScript
"use strict";
|
|
var port, server, service,
|
|
system = require('system');
|
|
|
|
if (system.args.length !== 2) {
|
|
console.log('Usage: serverkeepalive.js <portnumber>');
|
|
phantom.exit(1);
|
|
} else {
|
|
port = system.args[1];
|
|
server = require('webserver').create();
|
|
|
|
service = server.listen(port, { keepAlive: true }, function (request, response) {
|
|
console.log('Request at ' + new Date());
|
|
console.log(JSON.stringify(request, null, 4));
|
|
|
|
var body = JSON.stringify(request, null, 4);
|
|
response.statusCode = 200;
|
|
response.headers = {
|
|
'Cache': 'no-cache',
|
|
'Content-Type': 'text/plain',
|
|
'Connection': 'Keep-Alive',
|
|
'Keep-Alive': 'timeout=5, max=100',
|
|
'Content-Length': body.length
|
|
};
|
|
response.write(body);
|
|
response.close();
|
|
});
|
|
|
|
if (service) {
|
|
console.log('Web server running on port ' + port);
|
|
} else {
|
|
console.log('Error: Could not create web server listening on port ' + port);
|
|
phantom.exit();
|
|
}
|
|
}
|