| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a6e8368 commit b2248fd
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -982,6 +982,10 @@ function connectionCorkNT(conn) { | |||
| 982 | 982 | } | |
| 983 | 983 | ||
| 984 | 984 | OutgoingMessage.prototype.addTrailers = function addTrailers(headers) { | |
| 985 | + if (this.finished) { | ||
| 986 | + throw new ERR_HTTP_HEADERS_SENT('set trailing'); | ||
| 987 | + } | ||
| 988 | + | ||
| 985 | 989 | this._trailer = ''; | |
| 986 | 990 | const keys = ObjectKeys(headers); | |
| 987 | 991 | const isArray = ArrayIsArray(headers); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -129,6 +129,16 @@ assert.throws(() => { | |||
| 129 | 129 | message: 'Invalid character in trailer content ["404"]' | |
| 130 | 130 | }); | |
| 131 | 131 | ||
| 132 | + assert.throws(() => { | ||
| 133 | + const outgoingMessage = new OutgoingMessage(); | ||
| 134 | + outgoingMessage.finished = true; | ||
| 135 | + outgoingMessage.addTrailers({ 'x-foo': 'bar' }); | ||
| 136 | + }, { | ||
| 137 | + code: 'ERR_HTTP_HEADERS_SENT', | ||
| 138 | + name: 'Error', | ||
| 139 | + message: 'Cannot set trailing headers after they are sent to the client' | ||
| 140 | + }); | ||
| 141 | + | ||
| 132 | 142 | { | |
| 133 | 143 | const outgoingMessage = new OutgoingMessage(); | |
| 134 | 144 | assert.strictEqual(outgoingMessage.destroyed, false); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments