-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #255: stress issue with large upload and download
- Loading branch information
Showing
14 changed files
with
223 additions
and
12 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
A 30MB download | ||
*/ | ||
|
||
var assert = require('assert'); | ||
|
||
var timeout = setTimeout(function () { | ||
console.error('Timeout occurred'); | ||
assert.ok(false, 'request timed out'); | ||
}, 10000); | ||
|
||
var host = process.env.IISNODETEST_HOST || 'localhost'; | ||
var port = process.env.IISNODETEST_PORT || 31415; | ||
|
||
require('http').get('http://' + host + ':' + port + '/140_large_download/hello.js', function (res) { | ||
assert.equal(res.statusCode, 200); | ||
res.setEncoding('binary'); | ||
var contentLength = 0; | ||
res.on('data', function (data) { | ||
contentLength += data.length; | ||
}); | ||
res.on('end', function () { | ||
clearTimeout(timeout); | ||
assert.equal(contentLength, 30 * 1024 * 1024); | ||
}); | ||
}).on('error', function (e) { | ||
assert.ifError(e); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
A 31MB upload | ||
*/ | ||
|
||
var assert = require('assert'); | ||
|
||
var timeout = setTimeout(function () { | ||
console.error('Timeout occurred'); | ||
assert.ok(false, 'request timed out'); | ||
}, 10000); | ||
|
||
var host = process.env.IISNODETEST_HOST || 'localhost'; | ||
var port = process.env.IISNODETEST_PORT || 31415; | ||
|
||
var options = { | ||
hostname: host, | ||
port: port, | ||
path: '/141_large_upload/hello.js', | ||
method: 'POST' | ||
}; | ||
|
||
var req = require('http').request(options, function (res) { | ||
assert.equal(res.statusCode, 200); | ||
res.setEncoding('utf8'); | ||
var body = '' | ||
res.on('data', function (chunk) { | ||
body += chunk; | ||
}); | ||
res.on('end', function () { | ||
clearTimeout(timeout); | ||
assert.equal(body, 31 * 1024 * 1024); | ||
}); | ||
}); | ||
|
||
req.on('error', function (e) { | ||
assert.ifError(e); | ||
}); | ||
|
||
var buffer = new Buffer(1024); | ||
for (var i = 0; i < (31 * 1024) ; i++) | ||
req.write(buffer); | ||
req.end(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
A 31MB request with 30MB response | ||
*/ | ||
|
||
var assert = require('assert'); | ||
|
||
var timeout = setTimeout(function () { | ||
console.error('Timeout occurred'); | ||
assert.ok(false, 'request timed out'); | ||
}, 10000); | ||
|
||
var host = process.env.IISNODETEST_HOST || 'localhost'; | ||
var port = process.env.IISNODETEST_PORT || 31415; | ||
|
||
var options = { | ||
hostname: host, | ||
port: port, | ||
path: '/140_large_download/hello.js', | ||
method: 'POST' | ||
}; | ||
|
||
var req = require('http').request(options, function (res) { | ||
assert.equal(res.statusCode, 200); | ||
res.setEncoding('binary'); | ||
var contentLength = 0; | ||
res.on('data', function (data) { | ||
contentLength += data.length; | ||
}); | ||
res.on('end', function () { | ||
clearTimeout(timeout); | ||
assert.equal(contentLength, 30 * 1024 * 1024); | ||
}); | ||
}); | ||
|
||
req.on('error', function (e) { | ||
assert.ifError(e); | ||
}); | ||
|
||
var buffer = new Buffer(1024); | ||
for (var i = 0; i < (31 * 1024) ; i++) | ||
req.write(buffer); | ||
req.end(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var buffer = new Buffer(1024); | ||
var numKB = 1024 * 30; // 30MB downlaod | ||
|
||
require('http').createServer(function (req, res) { | ||
req.on('data', function (data) {} ); | ||
req.on('end', function () { | ||
res.writeHead(200, {'Content-Type': 'application/binary', 'Cache-Control': 'no-cache'}); | ||
for (var i = 0; i < numKB; i++) | ||
res.write(buffer); | ||
res.end(); | ||
}); | ||
}).listen(process.env.PORT || 3000); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<configuration> | ||
<system.webServer> | ||
<handlers> | ||
<add name="iisnode" path="hello.js" verb="*" modules="iisnode" /> | ||
</handlers> | ||
</system.webServer> | ||
</configuration> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require('http').createServer(function (req, res) { | ||
req.setEncoding('binary'); | ||
var contentLength = 0; | ||
req.on('data', function (data) { | ||
contentLength += data.length; | ||
}); | ||
req.on('end', function () { | ||
res.writeHead(200, {'Content-Type': 'text/plain', 'Cache-Control': 'no-cache'}); | ||
res.end('' + contentLength); | ||
}); | ||
}).listen(process.env.PORT || 3000); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<configuration> | ||
<system.webServer> | ||
<handlers> | ||
<add name="iisnode" path="hello.js" verb="*" modules="iisnode" /> | ||
</handlers> | ||
</system.webServer> | ||
</configuration> |