Browse Source

Safe constructors: http.Server and http.Client

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
44a287987e
  1. 2
      lib/http.js
  2. 2
      test/simple/test-http.js

2
lib/http.js

@ -730,6 +730,7 @@ function httpSocketSetup (socket) {
function Server (requestListener) { function Server (requestListener) {
if (!(this instanceof Server)) return new Server(requestListener);
net.Server.call(this); net.Server.call(this);
if(requestListener){ if(requestListener){
@ -851,6 +852,7 @@ function connectionListener (socket) {
function Client ( ) { function Client ( ) {
if (!(this instanceof Client)) return new Client();
net.Stream.call(this); net.Stream.call(this);
var self = this; var self = this;

2
test/simple/test-http.js

@ -12,7 +12,7 @@ var responses_recvd = 0;
var body0 = ""; var body0 = "";
var body1 = ""; var body1 = "";
var server = http.createServer(function (req, res) { var server = http.Server(function (req, res) {
if (responses_sent == 0) { if (responses_sent == 0) {
assert.equal("GET", req.method); assert.equal("GET", req.method);
assert.equal("/hello", url.parse(req.url).pathname); assert.equal("/hello", url.parse(req.url).pathname);

Loading…
Cancel
Save