Skip to content

Response headers in didFinishUpload delegate + data race fix (supersedes #167) - #231

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

Response headers in didFinishUpload delegate + data race fix (supersedes #167)#231
LefterisHaritou wants to merge 2 commits into
tus:mainfrom
LefterisHaritou:feature/response-header-in-didFinishUpload-delegate

Conversation

@LefterisHaritou

Copy link
Copy Markdown

Summary

Adds HTTP response header support to the didFinishUpload delegate callback, and fixes a data race in TUSAPI.

This continues and fixes the work started in #167 (by @srvarma7), rebased on top of the latest main (including the progress-wiring changes from #228).

What's included

  • Expose response headers on completion. A new didFinishUpload(id:url:context:client:responseHeaders:) delegate method surfaces the server's response headers. The previous signature is kept as a deprecated compatibility shim that forwards to the new method, so existing conformers keep working without changes.
  • New HTTPURLResponse+Headers extension to extract headers into a [String: String] dictionary.
  • Propagate headers into metadata. UploadDataTask now unpacks the upload result as (offset, responseHeaders) and stores responseHeaders on UploadMetadata.
  • Tolerant decoding / fix data racing. UploadMetadata decodes responseHeaders with decodeIfPresent, so older persisted metadata without that key won't fail to decode. TUSAPI callback handling was adjusted to avoid a data race on the shared callback state.

Relationship to #167

This supersedes #167 with the missing fix applied and a clean rebase onto current main. Happy to close #167 in favor of this if preferred.

Testing

  • swift build succeeds (only the expected deprecation warning from the intentional compatibility shim).

@donnywals

Copy link
Copy Markdown
Collaborator

Hi @LefterisHaritou, In order to merge this PR I will need to have the commits created with a verified signature.

You can find more information about this here: https://docs.github.com/en/authentication/managing-commit-signature-verification

srvarma7 and others added 2 commits August 3, 2026 14:00
UploadDataTask now unpacks the upload result as (offset, responseHeaders) and saves responseHeaders into UploadMetadata. UploadMetadata decoding was made tolerant by using decodeIfPresent for responseHeaders so older metadata without that key won't fail decoding. This propagates server response headers into metadata and avoids crashes when the field is missing.
@LefterisHaritou
LefterisHaritou force-pushed the feature/response-header-in-didFinishUpload-delegate branch from fd7aff9 to 86b9c81 Compare August 3, 2026 11:00
@LefterisHaritou

Copy link
Copy Markdown
Author

Hi @LefterisHaritou, In order to merge this PR I will need to have the commits created with a verified signature.

You can find more information about this here: https://docs.github.com/en/authentication/managing-commit-signature-verification

Should be ok now @donnywals ! Thanks

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.

3 participants