summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-server-unconsume.js
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2015-08-11 20:02:22 -0700
committerFedor Indutny <fedor@indutny.com>2015-08-26 12:45:22 -0700
commit607bbd3166b0b3bd6d3303b4115029b28b4283d0 (patch)
tree5d98f848e3d66e5806f022ae75ece033bf3db5dc /test/parallel/test-http-server-unconsume.js
parentb2660743470be1562a782f850a28349ceaf039ad (diff)
downloadnode-new-607bbd3166b0b3bd6d3303b4115029b28b4283d0.tar.gz
http_parser: consume StreamBase instance
Consume StreamBase instance and operate on incoming data directly without allocating Buffer instances. Improves performance. PR-URL: https://github.com/nodejs/node/pull/2355 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'test/parallel/test-http-server-unconsume.js')
-rw-r--r--test/parallel/test-http-server-unconsume.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/parallel/test-http-server-unconsume.js b/test/parallel/test-http-server-unconsume.js
new file mode 100644
index 0000000000..0d33263ad6
--- /dev/null
+++ b/test/parallel/test-http-server-unconsume.js
@@ -0,0 +1,30 @@
+'use strict';
+var common = require('../common');
+var assert = require('assert');
+var http = require('http');
+var net = require('net');
+
+var received = '';
+
+var server = http.createServer(function(req, res) {
+ res.writeHead(200);
+ res.end();
+
+ req.socket.on('data', function(data) {
+ received += data;
+ });
+
+ server.close();
+}).listen(common.PORT, function() {
+ var socket = net.connect(common.PORT, function() {
+ socket.write('PUT / HTTP/1.1\r\n\r\n');
+
+ socket.once('data', function() {
+ socket.end('hello world');
+ });
+ });
+});
+
+process.on('exit', function() {
+ assert.equal(received, 'hello world');
+});