-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set Upload-Length when appropriate #744
Open
Vija02
wants to merge
5
commits into
tus:main
Choose a base branch
from
Vija02:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
81f0a03
Feat: Set Upload-Length if we know the length and it's deferred from …
Vija02 3c0245d
Feat: Rename _deferred to _uploadLengthDeferred, set value in constru…
Vija02 8107fbd
Fix: Missed replace
Vija02 bc9efaf
Fix: Total size not calculated correctly when not last request
Vija02 d7521be
test: Upload-Defer-Length behaviour
Vija02 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just use
this._uploadLengthDeferred
here and don't need to consult the original option anymore.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That will change the behaviour quite a bit. As it is suggested right now, there's some problems:
this._uploadLengthDeferred
is true sinceoptions.uploadLengthDeferred
could be true. In this case, we'd send wrong info.done
will make it always pass the header at the end, which I believe isn't how it should work. It should only send the header on the next known request from what I understand.If we change it to an AND, it'll kinda work, but only send the length header at the end.
The logic in the commit right now expands to:
(this._uploadLengthDeferred && !this.options.uploadLengthDeferred)
Send header on next opportunity if the request is of known size
(this._uploadLengthDeferred && done)
And send at the end if it's a stream
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, my suggestion is wrong. I used
||
instead of&&
on accident and my suggestion would be:Yes, that's right and that's how tus-js-client has handled deferred lengths in the past. It always sent the length header once the file source is closed because then we know the file size for sure. I don't see a problem with keeping this behavior. Or do you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, I'm quite new to the protocol and library so I think you'd know more. But I was looking at this line over at the protocol documentation:
![image](https://private-user-images.githubusercontent.com/5815761/403458149-a51dee04-462c-47fc-b8f3-04c818036606.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0MDQxODcsIm5iZiI6MTczOTQwMzg4NywicGF0aCI6Ii81ODE1NzYxLzQwMzQ1ODE0OS1hNTFkZWUwNC00NjJjLTQ3ZmMtYjhmMy0wNGM4MTgwMzY2MDYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMjM0NDQ3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YWNiZmMwMDA2NTM3NDI4NjJhODIxMDY3ZjIzMmRlNTMzZDljMDAyNzI2MGY2Y2U5MDlhMTZiZjQzZjRhYzNlOCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.5tEV2nv9fgzBA8zs9CwDAeIO8FqEq0-NH8qJveDrPIQ)
That led me to believe that it should be the first possible instance. Although, I guess both ways should work anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Acconut, just want to bump this PR, any thoughts on this? Thanks 😄