A different approach to solve this could be to keep the Content-Length header (if the size can be determined) and drop the Transfer-Encoding instead.
But, there still needs to be support for the streaming case, which is used for such calls
curl $URL | glance add ...
The downside is that this would make the code slightly more complex.
Another way would be to always use chunked encoding without Content-Length, but have only one big chunk for files of known size, so that the server could determine if the size is acceptable right after receiving the first bytes.
A different approach to solve this could be to keep the Content-Length header (if the size can be determined) and drop the Transfer-Encoding instead.
But, there still needs to be support for the streaming case, which is used for such calls
curl $URL | glance add ...
The downside is that this would make the code slightly more complex.
Another way would be to always use chunked encoding without Content-Length, but have only one big chunk for files of known size, so that the server could determine if the size is acceptable right after receiving the first bytes.