Using URLRequest.httpBodyStream
can cause Violation of HTTP Spec
#4818
Labels
URLRequest.httpBodyStream
can cause Violation of HTTP Spec
#4818
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: