Node.js: is it possible to simulate an HTTP connection without external modules? -


let's assum have basic http server, 1 on nodejs.org:

var http = require('http'); http.createserver(function (req, res) {   res.writehead(200, {'content-type': 'text/plain'});   res.end('hello world\n'); }).listen(1337, '127.0.0.1'); console.log('server running @ http://127.0.0.1:1337/'); 

is possible simulate connection server without using npm module (socket.io, connect etc.) ?

the way have found using pure node.js using http.request , running both instances locally (both server , client simulator). however, unsure drawbacks has or if valid option. work if try simulate multiple connections, example? network speed bottleneck in case? there better/easier way?

sure, can make http request within computer, won't simulating either, you'll making actual connection too. nodejs's built in http module ships client server.

var http = require("http"); http.get("http://localhost:1337", function(resp){    console.log("request made!", resp); }); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -