From 6b6553e4d912c769e1307d66b0e4896fd7211190 Mon Sep 17 00:00:00 2001 From: Marius Kleidl Date: Mon, 18 Mar 2024 12:48:46 +0100 Subject: [PATCH] Update to draft -03 --- lib/upload.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/upload.js b/lib/upload.js index d576d214..e564de34 100644 --- a/lib/upload.js +++ b/lib/upload.js @@ -5,7 +5,7 @@ import { log } from './logger.js' import uuid from './uuid.js' const PROTOCOL_TUS_V1 = 'tus-v1' -const PROTOCOL_IETF_DRAFT_01 = 'ietf-draft-01' +const PROTOCOL_IETF_DRAFT_03 = 'ietf-draft-03' const defaultOptions = { endpoint: null, @@ -176,7 +176,7 @@ class BaseUpload { return } - if (![PROTOCOL_TUS_V1, PROTOCOL_IETF_DRAFT_01].includes(this.options.protocol)) { + if (![PROTOCOL_TUS_V1, PROTOCOL_IETF_DRAFT_03].includes(this.options.protocol)) { this._emitError(new Error(`tus: unsupported protocol ${this.options.protocol}`)) return } @@ -595,8 +595,8 @@ class BaseUpload { this._offset = 0 promise = this._addChunkToRequest(req) } else { - if (this.options.protocol === PROTOCOL_IETF_DRAFT_01) { - req.setHeader('Upload-Incomplete', '?1') + if (this.options.protocol === PROTOCOL_IETF_DRAFT_03) { + req.setHeader('Upload-Complete', '?0') } promise = this._sendRequest(req, null) } @@ -828,8 +828,8 @@ class BaseUpload { return this._sendRequest(req) } - if (this.options.protocol === PROTOCOL_IETF_DRAFT_01) { - req.setHeader('Upload-Incomplete', done ? '?0' : '?1') + if (this.options.protocol === PROTOCOL_IETF_DRAFT_03) { + req.setHeader('Upload-Complete', done ? '?1' : '?0') } this._emitProgress(this._offset, this._size) return this._sendRequest(req, value) @@ -962,8 +962,8 @@ function inStatusCategory(status, category) { function openRequest(method, url, options) { const req = options.httpStack.createRequest(method, url) - if (options.protocol === PROTOCOL_IETF_DRAFT_01) { - req.setHeader('Upload-Draft-Interop-Version', '3') + if (options.protocol === PROTOCOL_IETF_DRAFT_03) { + req.setHeader('Upload-Draft-Interop-Version', '5') } else { req.setHeader('Tus-Resumable', '1.0.0') }