Created
September 18, 2015 12:31
-
-
Save luke/8323cdf5e748e2bb298f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copy from node 0.12 source lib folder and add to your package.json | |
// | |
// "browser": { | |
// "net": "chrome-net", | |
// "http": "./http/http.js", | |
// "_http_agent": "./http/_http_agent.js", | |
// "_http_client": "./http/_http_client.js", | |
// "_http_common": "./http/_http_common.js", | |
// "_http_incoming": "./http/_http_incoming.js", | |
// "_http_outgoing": "./http/_http_outgoing.js", | |
// "_http_server": "./http/_http_server.js", | |
// "freelist": "./http/freelist.js" | |
// }, | |
var noop = function(){} | |
global.DTRACE_HTTP_SERVER_RESPONSE = noop | |
global.DTRACE_HTTP_SERVER_REQUEST = noop | |
global.DTRACE_HTTP_CLIENT_RESPONSE = noop | |
global.DTRACE_HTTP_CLIENT_REQUEST = noop | |
global.COUNTER_HTTP_SERVER_REQUEST = noop | |
global.COUNTER_HTTP_SERVER_RESPONSE = noop | |
global.COUNTER_HTTP_CLIENT_REQUEST = noop | |
global.COUNTER_HTTP_CLIENT_RESPONSE = noop | |
// monkey patch binding object browserify adds | |
binding = {} | |
process.binding = function(name){ | |
return binding | |
} | |
// swap out the http parser | |
process.binding('http_parser').HTTPParser = require('http-parser-js').HTTPParser; | |
// by default browserify will bundle http-browserify which we dont want | |
var http = require('http'); | |
var port = 4089; | |
function handleRequest(request, response){ | |
response.end('hello world'); | |
} | |
var server = http.createServer(handleRequest); | |
server.listen(port, function(){ | |
console.log("server listening on port "+port); | |
}) | |
var net = require('net'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment