Permalink
Browse files

NodeConf changes

  • Loading branch information...
lakenen committed Jul 2, 2013
1 parent b255f4c commit 41d028b2bc7184af10de5ae3087dfc311e99e068
Showing with 57 additions and 0 deletions.
  1. +12 −0 lib/_http_outgoing.js
  2. +4 −0 lib/net.js
  3. +8 −0 src/tcp_wrap.cc
  4. +1 −0 src/tcp_wrap.h
  5. +32 −0 test/simple/test-net-hello-world.js
@@ -577,3 +577,15 @@ OutgoingMessage.prototype._flush = function() {
this.emit('drain');
}
};

OutgoingMessage.prototype.json = function (obj, indent) {
try {
var response = JSON.stringify(obj, undefined, indent);
this.setHeader('Content-Type', 'application/json');
this.setHeader('Content-Length', response.length);
this.write(response);
} catch (e) {
this.emit('error');
}
this.end();
};
@@ -27,6 +27,10 @@ var assert = require('assert');
var cares = process.binding('cares_wrap');
var cluster;

exports.hello = function () {
return process.binding('tcp_wrap').hello();
};

function noop() {}

// constructor for lazy loading
@@ -56,6 +56,12 @@ typedef class ReqWrap<uv_connect_t> ConnectWrap;

Local<Object> AddressToJS(const sockaddr* addr);

Handle<Value> TCPWrap::Hello(const Arguments& args) {
// needed for GC magic
HandleScope scope;

return scope.Close(String::New("world"));
}

Local<Object> TCPWrap::Instantiate() {
// If this assert fire then process.binding('tcp_wrap') hasn't been
@@ -126,6 +132,8 @@ void TCPWrap::Initialize(Handle<Object> target) {
oncomplete_sym = NODE_PSYMBOL("oncomplete");

target->Set(String::NewSymbol("TCP"), tcpConstructor);

NODE_SET_METHOD(target, "hello", Hello);
}


@@ -48,6 +48,7 @@ class TCPWrap : public StreamWrap {
static v8::Handle<v8::Value> Connect(const v8::Arguments& args);
static v8::Handle<v8::Value> Connect6(const v8::Arguments& args);
static v8::Handle<v8::Value> Open(const v8::Arguments& args);
static v8::Handle<v8::Value> Hello(const v8::Arguments& args);

#ifdef _WIN32
static v8::Handle<v8::Value> SetSimultaneousAccepts(const v8::Arguments& args);
@@ -0,0 +1,32 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

var common = require('../common');
var assert = require('assert');

// Require the net module
var net = require('net');

assert.equal(typeof net.hello, 'function');

assert.equal(net.hello(), 'world');

console.log('ok');

0 comments on commit 41d028b

Please sign in to comment.