-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
test: adding Countdown to test-http-set-cookies test #17504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
3ef1c59
f855134
2676d7c
39f8099
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,21 +20,21 @@ | |
| // USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
|
||
| 'use strict'; | ||
| require('../common'); | ||
| const common = require('../common'); | ||
| const assert = require('assert'); | ||
| const http = require('http'); | ||
| const Countdown = require('../common/countdown'); | ||
|
|
||
| let nresponses = 0; | ||
|
|
||
| const countdown = new Countdown(2, common.mustCall(() => server.close())); | ||
| const server = http.createServer(function(req, res) { | ||
| if (req.url === '/one') { | ||
| res.writeHead(200, [['set-cookie', 'A'], | ||
| ['content-type', 'text/plain']]); | ||
| ['content-type', 'text/plain']]); | ||
|
||
| res.end('one\n'); | ||
| } else { | ||
| res.writeHead(200, [['set-cookie', 'A'], | ||
| ['set-cookie', 'B'], | ||
| ['content-type', 'text/plain']]); | ||
| ['set-cookie', 'B'], | ||
| ['content-type', 'text/plain']]); | ||
|
||
| res.end('two\n'); | ||
| } | ||
| }); | ||
|
|
@@ -44,7 +44,7 @@ server.on('listening', function() { | |
| // | ||
| // one set-cookie header | ||
| // | ||
| http.get({ port: this.address().port, path: '/one' }, function(res) { | ||
| http.get({port: this.address().port, path: '/one'}, function(res) { | ||
|
||
| // set-cookie headers are always return in an array. | ||
| // even if there is only one. | ||
| assert.deepStrictEqual(['A'], res.headers['set-cookie']); | ||
|
|
@@ -55,15 +55,13 @@ server.on('listening', function() { | |
| }); | ||
|
|
||
| res.on('end', function() { | ||
| if (++nresponses === 2) { | ||
| server.close(); | ||
| } | ||
| countdown.dec(); | ||
| }); | ||
| }); | ||
|
|
||
| // two set-cookie headers | ||
|
|
||
| http.get({ port: this.address().port, path: '/two' }, function(res) { | ||
| http.get({port: this.address().port, path: '/two'}, function(res) { | ||
|
||
| assert.deepStrictEqual(['A', 'B'], res.headers['set-cookie']); | ||
| assert.strictEqual('text/plain', res.headers['content-type']); | ||
|
|
||
|
|
@@ -72,14 +70,12 @@ server.on('listening', function() { | |
| }); | ||
|
|
||
| res.on('end', function() { | ||
| if (++nresponses === 2) { | ||
| server.close(); | ||
| } | ||
| countdown.dec(); | ||
| }); | ||
| }); | ||
|
|
||
| }); | ||
|
|
||
| process.on('exit', function() { | ||
| assert.strictEqual(2, nresponses); | ||
| assert.strictEqual(countdown.remaining, 0); | ||
|
||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't strictly need the
common.mustCallbut it's not a deal breaker. (If you do remove it, you'll need to also remove theconst common =part above (but keep the actualrequire).