summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2014-04-09 15:02:03 +0200
committerFedor Indutny <fedor@indutny.com>2014-04-24 10:43:51 +0400
commitbd24ab2bd788a196adaac316db20cde2c8c8e14d (patch)
tree62b4fac92504b0f57de2be52d865220e6e291762 /test
parenta60a9b0dbd064cd70de9400ad47421c19d29b021 (diff)
downloadandroid-node-v8-bd24ab2bd788a196adaac316db20cde2c8c8e14d.tar.gz
android-node-v8-bd24ab2bd788a196adaac316db20cde2c8c8e14d.tar.bz2
android-node-v8-bd24ab2bd788a196adaac316db20cde2c8c8e14d.zip
http: add request.flush() method
Forcibly flushes the request headers. You need this with long-lived HTTP connections where the first data isn't written until the connection has been established (think: tunneling requests over HTTP CONNECT.) Fixes #7296. Signed-off-by: Fedor Indutny <fedor@indutny.com>
Diffstat (limited to 'test')
-rw-r--r--test/simple/test-http-flush.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/simple/test-http-flush.js b/test/simple/test-http-flush.js
new file mode 100644
index 0000000000..7da94e89dc
--- /dev/null
+++ b/test/simple/test-http-flush.js
@@ -0,0 +1,37 @@
+// 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');
+var http = require('http');
+
+http.createServer(function(req, res) {
+ res.end('ok');
+ this.close();
+}).listen(function() {
+ var req = http.request({
+ method: 'POST',
+ host: this.address().address,
+ port: this.address().port,
+ });
+ req.flush(); // Flush the request headers.
+ req.flush(); // Should be idempotent.
+});