Servers responding with a Transfer-Encoding: chunked should be supported.
Actual behavior
"Missing Content-Length header" error is displayed.
Steps to reproduce
Run swift package-collection add with a Swift Package Collection that supports chunked encoding
If possible, minimal yet complete reproducer code (or URL to code)
swift package-collection add <url that supports chunking>
For example, hosting with Next.js will support chunked responses for static files by default.
Swift Package Manager version/commit hash
Current main (c0d5daa8fb43d87a6043a79c3cd132987eb40623), whatever is shipped with Xcode 13.2.1
Swift & OS version (output of swift --version && uname -a)
swift-driver version: 1.26.21 Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)
Target: arm64-apple-macosx12.0
Darwin M1-MacBook-Pro.lan 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:46:32 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T6000 arm64
we can probably relax the requirement on content-length header when detecting streamed content as we have a secondary size protection for streamed payloads
Expected behavior
Servers responding with a
Transfer-Encoding: chunked
should be supported.Actual behavior
"Missing Content-Length header" error is displayed.
Steps to reproduce
swift package-collection add
with a Swift Package Collection that supports chunked encodingIf possible, minimal yet complete reproducer code (or URL to code)
swift package-collection add <url that supports chunking>
For example, hosting with Next.js will support chunked responses for static files by default.
Swift Package Manager version/commit hash
Current
main
(c0d5daa8fb43d87a6043a79c3cd132987eb40623), whatever is shipped with Xcode 13.2.1Swift & OS version (output of
swift --version && uname -a
)More Info
The
Accept-Encoding
header is being set todeflate, identity, gzip;q=0
: https://github.com/apple/swift-package-manager/blob/main/Sources/PackageCollections/Providers/JSONPackageCollectionProvider.swift#L305. Whengzip
ordeflate
are used the response may be chunked, which causes theContent-Length
header to not be included.