Merge pull request #1923 from jpmoodlerooms/listen_bug

express.listen() should return http.Server
This commit is contained in:
Masahiro Wakame
2014-04-01 22:53:16 +09:00
4 changed files with 34 additions and 19 deletions
+7
View File
@@ -1489,3 +1489,10 @@ function test_middleware() {
app.use(express.static('public'));
app.use(router.middleware);
}
////////////////////
// make sure server can be shut down
var testShutdownServer = app.listen(0);
console.log('listening on port ' + testShutdownServer.address().port);
testShutdownServer.close();
+5 -5
View File
@@ -1112,15 +1112,15 @@ declare module "express" {
* http.createServer(app).listen(80);
* https.createServer({ ... }, app).listen(443);
*/
listen(port: number, hostname: string, backlog: number, callback?: Function): void;
listen(port: number, hostname: string, backlog: number, callback?: Function): http.Server;
listen(port: number, hostname: string, callback?: Function): void;
listen(port: number, hostname: string, callback?: Function): http.Server;
listen(port: number, callback?: Function): void;
listen(port: number, callback?: Function): http.Server;
listen(path: string, callback?: Function): void;
listen(path: string, callback?: Function): http.Server;
listen(handle: any, listeningListener?: Function): void;
listen(handle: any, listeningListener?: Function): http.Server;
route: IRoute;
+8 -1
View File
@@ -7,6 +7,8 @@ import zlib = require("zlib");
import url = require('url');
import util = require("util");
import crypto = require("crypto");
import http = require("http");
import net = require("net");
assert(1 + 1 - 2 === 0, "The universe isn't how it should.");
@@ -82,9 +84,14 @@ function stream_readable_pipe_test() {
r.pipe(z).pipe(w);
}
////////////////////////////////////////////////////
/// Crypto tests : http://nodejs.org/api/crypto.html
////////////////////////////////////////////////////
var hmacResult: string = crypto.createHmac('md5', 'hello').update('world').digest('hex');
////////////////////////////////////////////////////
// Make sure .listen() and .close() retuern a Server instance
http.createServer().listen(0).close().address();
net.createServer().listen(0).close().address();
+14 -13
View File
@@ -252,10 +252,11 @@ declare module "http" {
import stream = require("stream");
export interface Server extends NodeEventEmitter {
listen(port: number, hostname?: string, backlog?: number, callback?: Function): void;
listen(path: string, callback?: Function): void;
listen(handle: any, listeningListener?: Function): void;
close(cb?: any): void;
listen(port: number, hostname?: string, backlog?: number, callback?: Function): Server;
listen(path: string, callback?: Function): Server;
listen(handle: any, listeningListener?: Function): Server;
close(cb?: any): Server;
address(): { port: number; family: string; address: string; };
maxHeadersCount: number;
}
export interface ServerRequest extends NodeEventEmitter, ReadableStream {
@@ -711,10 +712,10 @@ declare module "net" {
};
export interface Server extends Socket {
listen(port: number, host?: string, backlog?: number, listeningListener?: Function): void;
listen(path: string, listeningListener?: Function): void;
listen(handle: any, listeningListener?: Function): void;
close(callback?: Function): void;
listen(port: number, host?: string, backlog?: number, listeningListener?: Function): Server;
listen(path: string, listeningListener?: Function): Server;
listen(handle: any, listeningListener?: Function): Server;
close(callback?: Function): Server;
address(): { port: number; family: string; address: string; };
maxConnections: number;
connections: number;
@@ -957,12 +958,12 @@ declare module "tls" {
export interface Server extends net.Server {
// Extended base methods
listen(port: number, host?: string, backlog?: number, listeningListener?: Function): void;
listen(path: string, listeningListener?: Function): void;
listen(handle: any, listeningListener?: Function): void;
listen(port: number, host?: string, backlog?: number, listeningListener?: Function): Server;
listen(path: string, listeningListener?: Function): Server;
listen(handle: any, listeningListener?: Function): Server;
listen(port: number, host?: string, callback?: Function): void;
close(): void;
listen(port: number, host?: string, callback?: Function): Server;
close(): Server;
address(): { port: number; family: string; address: string; };
addContext(hostName: string, credentials: {
key: string;