diff --git a/test/simple/test-http-upgrade-client.js b/test/simple/test-http-upgrade-client.js index be6c386ef2..4ee5d96f20 100644 --- a/test/simple/test-http-upgrade-client.js +++ b/test/simple/test-http-upgrade-client.js @@ -38,10 +38,9 @@ srv.listen(common.PORT, '127.0.0.1', function () { assert.equal(upgradeHead, 'nurtzo'); console.log(res.headers); - var expectedHeaders = { "hello": "world" - , "connection": "upgrade" - , "upgrade": "websocket" - }; + var expectedHeaders = { "hello": "world", + "connection": "upgrade", + "upgrade": "websocket" }; assert.deepEqual(expectedHeaders, res.headers); socket.end(); diff --git a/test/simple/test-http-upgrade-client2.js b/test/simple/test-http-upgrade-client2.js index b7fbf9db37..5048505912 100644 --- a/test/simple/test-http-upgrade-client2.js +++ b/test/simple/test-http-upgrade-client2.js @@ -4,12 +4,12 @@ var http = require('http'), CRLF = '\r\n'; var server = http.createServer(); -server.on('upgrade', function(req, socket, head) { +server.on('upgrade', function(req, socket, head) { socket.write('HTTP/1.1 101 Ok' + CRLF + 'Connection: Upgrade' + CRLF + 'Upgrade: Test' + CRLF + CRLF + 'head'); socket.on('end', function () { - socket.end(); + socket.end(); }); }); @@ -19,40 +19,37 @@ server.listen(common.PORT, function () { var client = http.createClient(common.PORT); function upgradeRequest(fn) { - var request = client.request('GET', '/', { - 'Connection': 'Upgrade', - 'Upgrade': 'Test' - }); - + var header = { 'Connection': 'Upgrade', 'Upgrade': 'Test' }; + var request = client.request('GET', '/', header); var wasUpgrade = false; - + function onUpgrade(res, socket, head) { wasUpgrade = true; - + client.removeListener('upgrade', onUpgrade); - socket.end(); + socket.end(); } client.on('upgrade', onUpgrade); - + function onEnd() { client.removeListener('end', onEnd); if (!wasUpgrade) { throw new Error('hasn\'t received upgrade event'); - } else { + } else { fn && process.nextTick(fn); } } client.on('end', onEnd); - + request.write('head'); } successCount = 0; upgradeRequest(function() { - successCount++; + successCount++; upgradeRequest(function() { - successCount++; + successCount++; // Test pass console.log('Pass!'); client.end(); diff --git a/test/simple/test-http-upgrade-server.js b/test/simple/test-http-upgrade-server.js index 9d2f07597f..accc18bcca 100644 --- a/test/simple/test-http-upgrade-server.js +++ b/test/simple/test-http-upgrade-server.js @@ -29,11 +29,10 @@ function testServer(){ }); server.addListener("upgrade", function(req, socket, upgradeHead){ - socket.write( "HTTP/1.1 101 Web Socket Protocol Handshake\r\n" - + "Upgrade: WebSocket\r\n" - + "Connection: Upgrade\r\n" - + "\r\n\r\n" - ); + socket.write("HTTP/1.1 101 Web Socket Protocol Handshake\r\n" + + "Upgrade: WebSocket\r\n" + + "Connection: Upgrade\r\n" + + "\r\n\r\n"); request_upgradeHead = upgradeHead; @@ -66,13 +65,11 @@ function test_upgrade_with_listener(_server){ var state = 0; conn.addListener("connect", function () { - writeReq( conn - , "GET / HTTP/1.1\r\n" - + "Upgrade: WebSocket\r\n" - + "Connection: Upgrade\r\n" - + "\r\n" - + "WjN}|M(6" - ); + writeReq(conn, "GET / HTTP/1.1\r\n" + + "Upgrade: WebSocket\r\n" + + "Connection: Upgrade\r\n" + + "\r\n" + + "WjN}|M(6"); }); conn.addListener("data", function (data) { diff --git a/test/simple/test-http-upgrade-server2.js b/test/simple/test-http-upgrade-server2.js index 7de161ade6..ade541ac62 100644 --- a/test/simple/test-http-upgrade-server2.js +++ b/test/simple/test-http-upgrade-server2.js @@ -31,11 +31,10 @@ server.listen(common.PORT, function () { c.addListener('connect', function () { common.error('client wrote message'); - c.write( "GET /blah HTTP/1.1\r\n" - + "Upgrade: WebSocket\r\n" - + "Connection: Upgrade\r\n" - + "\r\n\r\nhello world" - ); + c.write("GET /blah HTTP/1.1\r\n" + + "Upgrade: WebSocket\r\n" + + "Connection: Upgrade\r\n" + + "\r\n\r\nhello world"); }); c.addListener('end', function () {