Skip to content
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

Import HTTP resumable upload sample code #203

Merged
merged 18 commits into from
Dec 11, 2024

Conversation

guoye-zhang
Copy link
Contributor

@guoye-zhang guoye-zhang commented Jul 10, 2023

Support HTTP resumable upload.

Motivation:

Supporting HTTP resumable upload protocol defined in https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-resumable-upload-05

  • Interop version 3: iOS 17.0, macOS 14.0
  • Interop version 5: iOS 18.0, macOS 15.0
  • Interop version 6: iOS 18.1, macOS 15.1

Modifications:

2 new public classes, HTTPResumableUploadHandler and HTTPResumableUploadContext, and a few other supporting objects to manage resumable uploads and translate them into regular uploads.

@Lukasa Lukasa added the 🆕 semver/minor Adds new public API. label Oct 26, 2023
@Lukasa
Copy link
Contributor

Lukasa commented Oct 26, 2023

@FranzBusch want to take another quick look at this?

Copy link
Member

@FranzBusch FranzBusch left a comment

Choose a reason for hiding this comment

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

Left some smaller comments inline but this is not going to be usable from our new async APIs since we lose type information in the pipeline. Furthermore, I think with our new async APIs we would implement all of this in Swift Concurrency in an HTTP Server and not inside the NIO channel pipeline. I am wondering if it makes sense to add this here or just defer it functionality that our general purpose HTTP server should handle. @Lukasa WDYT?

@Lukasa
Copy link
Contributor

Lukasa commented Oct 26, 2023

I think we should add this here: it's in support of sample code that was released with WWDC, and we should be willing to support that code.

//
//===----------------------------------------------------------------------===//

import Foundation
Copy link
Contributor Author

@guoye-zhang guoye-zhang Nov 3, 2024

Choose a reason for hiding this comment

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

Unfortunately had to import Foundation to use FileHandle for cross-platform file IO

switch request.method {
case .post, .put:
if let requestPath = request.path {
let path = self.directory.appending(requestPath)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This might be a bad idea since people can send ../ in the request path

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm now using standardized URL and comparing the prefix which hopefully addresses the issue

@Lukasa Lukasa enabled auto-merge (squash) December 11, 2024 07:36
@Lukasa Lukasa merged commit fde9d65 into apple:main Dec 11, 2024
22 checks passed
@guoye-zhang guoye-zhang deleted the resumable-upload branch December 11, 2024 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants