We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 03643c5 commit dbc9c5aCopy full SHA for dbc9c5a
2 files changed
__tests__/response/length.js
@@ -64,3 +64,18 @@ describe('res.length', () => {
64
});
65
66
67
+
68
+describe('res.length=', () => {
69
+ it('should set when Transfer-Encoding not present', () => {
70
+ const res = response();
71
+ res.length = 100;
72
+ assert.strictEqual(res.length, 100);
73
+ });
74
75
+ it('should not set when Transfer-Encoding present', () => {
76
77
+ res.set('Transfer-Encoding', 'chunked');
78
79
+ assert.strictEqual(res.length, undefined);
80
81
+});
lib/response.js
@@ -191,7 +191,9 @@ module.exports = {
191
*/
192
193
set length(n) {
194
- this.set('Content-Length', n);
+ if (!this.has('Transfer-Encoding')) {
195
+ this.set('Content-Length', n);
196
+ }
197
},
198
199
/**
0 commit comments