Skip to content

Commit 8607abe

Browse files
author
Ben Stahl
committed
Upload-Defer-Length should only be set if Upload-Length is unknown
1 parent 0f1a2bb commit 8607abe

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

lib/handlers/HeadHandler.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class HeadHandler extends BaseHandler {
3535
res.setHeader('Upload-Length', file.upload_length);
3636
}
3737

38-
if ('upload_defer_length' in file) {
39-
// If the size of the upload is known, the Server MUST include
40-
// the Upload-Length header in the response.
38+
if (!('upload_length' in file) && 'upload_defer_length' in file) {
39+
// As long as the length of the upload is not known, the Server
40+
// MUST set Upload-Defer-Length: 1 in all responses to HEAD requests.
4141
res.setHeader('Upload-Defer-Length', file.upload_defer_length);
4242
}
4343

test/Test-FileStore.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,18 @@ describe('FileStore', () => {
183183
});
184184

185185
it('should return the defer header for deferred files', (done) => {
186+
request(server.listen())
187+
.head(`${STORE_PATH}/${deferred_file_path}`)
188+
.set('Tus-Resumable', TUS_RESUMABLE)
189+
.expect(200)
190+
.end((err, res) => {
191+
assert.equal(res.headers['upload-defer-length'], 1);
192+
assert.equal(res.headers['upload-length'], undefined);
193+
done();
194+
});
195+
});
196+
197+
it('should return the upload metatata', (done) => {
186198
request(server.listen())
187199
.head(`${STORE_PATH}/${created_file_path}`)
188200
.set('Tus-Resumable', TUS_RESUMABLE)

0 commit comments

Comments
 (0)