-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
http: align with stream.Writable #31818
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 all commits
3d6d1bb
70b2b52
9d74039
37ee279
8c31863
9018a77
406e65f
ed2dd71
1b51407
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
const http = require('http'); | ||
const OutgoingMessage = http.OutgoingMessage; | ||
|
||
{ | ||
const msg = new OutgoingMessage(); | ||
assert.strictEqual(msg.destroyed, false); | ||
msg.destroy(); | ||
assert.strictEqual(msg.destroyed, true); | ||
let callbackCalled = false; | ||
msg.write('asd', common.mustCall((err) => { | ||
assert.strictEqual(err.code, 'ERR_STREAM_DESTROYED'); | ||
callbackCalled = true; | ||
})); | ||
msg.on('error', common.mustCall((err) => { | ||
assert.strictEqual(err.code, 'ERR_STREAM_DESTROYED'); | ||
assert.strictEqual(callbackCalled, true); | ||
})); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,16 +74,14 @@ assert.throws(() => { | |
); | ||
} | ||
|
||
assert(OutgoingMessage.prototype.write.call({ _header: 'test' })); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Notice, this will now throw |
||
|
||
assert.throws(() => { | ||
const outgoingMessage = new OutgoingMessage(); | ||
outgoingMessage.write.call({ _header: 'test', _hasBody: 'test' }); | ||
}, { | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
name: 'TypeError', | ||
message: 'The first argument must be of type string or an instance of ' + | ||
'Buffer. Received undefined' | ||
message: 'The "chunk" argument must be of type string or an instance of ' + | ||
'Buffer or Uint8Array. Received undefined' | ||
}); | ||
|
||
assert.throws(() => { | ||
|
@@ -92,8 +90,16 @@ assert.throws(() => { | |
}, { | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
name: 'TypeError', | ||
message: 'The first argument must be of type string or an instance of ' + | ||
'Buffer. Received type number (1)' | ||
message: 'The "chunk" argument must be of type string or an instance of ' + | ||
'Buffer or Uint8Array. Received type number (1)' | ||
}); | ||
|
||
assert.throws(() => { | ||
const outgoingMessage = new OutgoingMessage(); | ||
outgoingMessage.write.call({ _header: 'test', _hasBody: 'test' }, null); | ||
}, { | ||
code: 'ERR_STREAM_NULL_VALUES', | ||
name: 'TypeError' | ||
}); | ||
|
||
// addTrailers() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,8 +34,8 @@ const server = http.Server(common.mustCall(function(req, res) { | |
res.end(); | ||
|
||
const r = res.write('This should raise an error.'); | ||
// Write after end should return true | ||
assert.strictEqual(r, true); | ||
// Write after end should return false | ||
assert.strictEqual(r, false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please note this. For some reason write after end would return |
||
})); | ||
|
||
server.listen(0, function() { | ||
|
Uh oh!
There was an error while loading. Please reload this page.