Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial failing test on account of headers

  • Loading branch information...
commit 523a1e3093c4328b1ac1c35d004f714b6ef0a54c 1 parent a33457f
@substack authored
Showing with 93 additions and 0 deletions.
  1. +18 −0 LICENSE
  2. +36 −0 package.json
  3. +39 −0 test/server.js
View
18 LICENSE
@@ -0,0 +1,18 @@
+This software is released under the MIT license:
+
+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.
View
36 package.json
@@ -0,0 +1,36 @@
+{
+ "name" : "http-noupgrade",
+ "version" : "0.0.0",
+ "description" : "merge upgrade requests back into the request listener",
+ "main" : "index.js",
+ "bin" : {},
+ "directories" : {
+ "example" : "example",
+ "test" : "test"
+ },
+ "dependencies" : {},
+ "devDependencies" : {
+ "tap" : "~0.3.0"
+ },
+ "scripts" : {
+ "test" : "tap test/*.js"
+ },
+ "repository" : {
+ "type" : "git",
+ "url" : "git://github.com/substack/http-noupgrade.git"
+ },
+ "homepage" : "https://github.com/substack/http-noupgrade",
+ "keywords" : [
+ "http",
+ "server",
+ "experiment",
+ "upgrade",
+ "request"
+ ],
+ "author" : {
+ "name" : "James Halliday",
+ "email" : "mail@substack.net",
+ "url" : "http://substack.net"
+ },
+ "license" : "MIT"
+}
View
39 test/server.js
@@ -0,0 +1,39 @@
+var http = require('../');
+var test = require('tap').test;
+
+test(function (t) {
+ t.plan(2);
+
+ var server = http.createServer(function (req, res) {
+ if (req.headers.upgrade) {
+ req.on('data', function (buf) {
+ res.write(String(buf).toUpperCase());
+ });
+ }
+ else res.end('beep boop');
+ });
+ server.listen();
+ var port = server.address().port;
+
+ server.on('listening', function () {
+ var opts = {
+ host : 'localhost',
+ port : port,
+ path : '/',
+ headers : { upgrade : true }
+ };
+ var r = http.request(opts, function (res) {
+ t.same(res.headers, {});
+
+ res.on('data', function (buf) {
+ t.equal(String(buf), 'BEEP\n');
+ r.end();
+ });
+ });
+ r.write('beep\n');
+ });
+
+ t.on('end', function () {
+ server.close();
+ });
+});
Please sign in to comment.
Something went wrong with that request. Please try again.