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
Using URLRequest.httpBodyStream
can cause Violation of HTTP Spec
#4818
Comments
Hmmm, since this is about URLSession and corelibs the bug should probably be moved over there -- I'll do that. Do note however that rather than fixing corelibs it is likely that the correct behavior should instead be implemnted in the swift-foundation reimplementation over here: https://github.com/apple/swift-foundation
FYI @parkera |
Thanks a lot. 🙏 I originally wanted to file the bug on
Should I file another bug to update the file? |
Description
When using
URLRequest.httpBodyStream
and specifying theContent-Length
header,swift-corelibs-foundation
's implementation ofURLSession
sends both theContent-Length
and theTransfer-Encoding
headers.This seems to violate RFC 9112, Section 6.2, Content-Length:
Steps to reproduce
As the reproduction of this issue is quite complicated, I created a repository with:
URLSession
docker compose
that can be used to reproduce this behavior using a few command line invocations (see readme.md for details).Expected behavior
Darwin's
Foundation
solves this issue by trusting and sending theContent-Length
header (instead ofTransfer-Encoding
) along with thehttpBodyStream
(without applying thechunked
transfer encoding).swift-async-http-client
seems to exhibit the same behavior.I propose to have the current implementation of
URLSession
aligned with the implementations of Darwin'sURLSession
andswift-async-http-client
.Environment
The text was updated successfully, but these errors were encountered: