Skip to content

Feature/response header in did finish upload delegate#167

Open
srvarma7 wants to merge 9 commits into
tus:mainfrom
srvarma7:feature/response-header-in-didFinishUpload-delegate
Open

Feature/response header in did finish upload delegate#167
srvarma7 wants to merge 9 commits into
tus:mainfrom
srvarma7:feature/response-header-in-didFinishUpload-delegate

Conversation

@srvarma7

Copy link
Copy Markdown
Contributor

No description provided.

@srvarma7

Copy link
Copy Markdown
Contributor Author

@Acconut @donnywals
This is the conflict resolved PR for closed PR.
I've made some improvements and was having a trouble with branch name change (master -> main) with the last PR. Hence closed.
Thank you.

Comment thread Sources/TUSKit/TUSClient.swift Outdated
func didStartUpload(id: UUID, context: [String: String]?, client: TUSClient)
/// `TUSClient` just finished an upload, returns the URL of the uploaded file.
func didFinishUpload(id: UUID, url: URL, context: [String: String]?, client: TUSClient)
func didFinishUpload(id: UUID, url: URL, responseHeaders: [String: String]?, context: [String: String]?, client: TUSClient)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding support for response headers this way makes this PR a breaking change which I want to avoid.

We could have both versions of didFinishUpload with and without the responseHeaders defined on this protocol. Both would need to be called from the places where we call delegate?.didFinishUpload which would be error prone so expanding the test suite to verify we always call both would be desirable.

If you have other ideas to implement this as a non-breaking change, I'm all ears 👍🏼

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made the above change making func didFinishUpload(id: UUID, url: URL, context: [String: String]?, client: TUSClient, responseHeaders: [String: String]?) an optional function and called both the functions in a private function.
In the mock test, I've just added a skeleton that confirms to the optional delegate method. Could you please suggest me to how to make the test case work with the changes?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try and take a detailed look at that later this week, possibly next week. I'm currently on vacation so only have very short bursts of time to look at PRs and do bits of work.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Have a nice vacation.
Will be looking forward for your feedback after your vacation.

}

/// `TUSClient` just finished an upload, returns the URL of the uploaded file along with `responseHeaders` from server.
func didFinishUpload(id: UUID, url: URL, context: [String: String]?, client: TUSClient, responseHeaders: [String: String]?) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I actually think this would still be breaking since if I conform to the delegate protocol I must implement all methods required by the protocol. This slipped my mind earlier.

Maybe we can provide a default empty implementation in a protocol extension for this method so that existing users of the SDK wouldn't have to do any work after updating?

I do wonder if we could mark a protocol method as deprecated. If we can, we could deprecate the old one and tell clients to implement the new method

Addition of didFinishUpload with responseHeader in TUSClientDelegate protocol definition.
@kvz

kvz commented Sep 26, 2024

Copy link
Copy Markdown
Member

Hi, should we close this?

@donnywals

Copy link
Copy Markdown
Collaborator

Will close due to inactivity

@donnywals donnywals closed this Oct 3, 2024
@LefterisHaritou

Copy link
Copy Markdown

Why didn't we end up implementing this? We kinda need this responseHeaders. An empty protocol extension implementation should fix the breaking protocol changes.

@donnywals

Copy link
Copy Markdown
Collaborator

@LefterisHaritou given that there was no activity on the PR to resolve breaking changes we closed the issue (and no further customer requests were submitted asking for this feature).

You're more than welcome to pick this one up and implementing your suggestion and I'm happy to review and merge this.

@srvarma7

Copy link
Copy Markdown
Contributor Author

I can make the change and push it. Thanks.

@srvarma7

Copy link
Copy Markdown
Contributor Author

@donnywals, I'm unable to reopen this PR from my side as the reopen button isn't available.

I have rebased the code to adapt to recent changes, made some updates, and pushed them to my forked branch. Additionally, as you suggested, I've marked the old function as deprecated.

Could you please check if you can reopen the PR from your side?

@Acconut Acconut reopened this Jun 17, 2026
@Acconut

Acconut commented Jun 17, 2026

Copy link
Copy Markdown
Member

@srvarma7 I just reopened the PR.

@srvarma7 srvarma7 force-pushed the feature/response-header-in-didFinishUpload-delegate branch from 6a1a13c to 262c1c5 Compare June 18, 2026 04:25
@srvarma7 srvarma7 force-pushed the feature/response-header-in-didFinishUpload-delegate branch from 262c1c5 to cfad9de Compare June 18, 2026 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants