Skip to content

Commit

Permalink
Update to draft -03
Browse files Browse the repository at this point in the history
  • Loading branch information
Acconut committed Mar 18, 2024
1 parent e607a66 commit 6b6553e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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')
}
Expand Down

0 comments on commit 6b6553e

Please sign in to comment.