Skip to content

Commit

Permalink
Safe constructors: http.Server and http.Client
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Aug 27, 2010
1 parent e8b3751 commit 44a2879
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ function httpSocketSetup (socket) {


function Server (requestListener) {
if (!(this instanceof Server)) return new Server(requestListener);
net.Server.call(this);

if(requestListener){
Expand Down Expand Up @@ -851,6 +852,7 @@ function connectionListener (socket) {


function Client ( ) {
if (!(this instanceof Client)) return new Client();
net.Stream.call(this);
var self = this;

Expand Down
2 changes: 1 addition & 1 deletion test/simple/test-http.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var responses_recvd = 0;
var body0 = "";
var body1 = "";

var server = http.createServer(function (req, res) {
var server = http.Server(function (req, res) {
if (responses_sent == 0) {
assert.equal("GET", req.method);
assert.equal("/hello", url.parse(req.url).pathname);
Expand Down

0 comments on commit 44a2879

Please sign in to comment.