Created
September 12, 2013 00:27
-
-
Save ericelliott/6531724 to your computer and use it in GitHub Desktop.
Easy to crash express service.
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
Unexpected end of input | |
SyntaxError: Unexpected end of input | |
at Object.parse (native) | |
at IncomingMessage.module.exports (/Users/erhamilt/dev/ccweb-main/node_modules/connect/lib/middleware/json.js:76:27) | |
at IncomingMessage.EventEmitter.emit (events.js:93:17) | |
at IncomingMessage._emitEnd (http.js:366:10) | |
at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23) | |
at Socket.socket.ondata (http.js:1825:22) | |
at TCP.onread (net.js:404:27) |
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
var http = require('http'); | |
var data = JSON.stringify({ | |
firstName: 'JoaquÌn. Do you get it', | |
}); | |
var options = { | |
host: 'localhost', | |
port: 8888, | |
path: '/', | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
'Content-Length': data.length | |
} | |
}; | |
var requests = 10000; | |
function doRequest() { | |
var req = http.request(options, function(res) { | |
var result = ''; | |
res.on('data', function(chunk) { | |
result += chunk; | |
}); | |
res.on('end', function() { | |
console.log(result); | |
}); | |
}); | |
req.on('error', function(err) { | |
console.log(err); | |
}); | |
req.write(data); | |
req.end(); | |
} | |
while (requests) { | |
doRequest(); | |
requests--; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment