Closed cnblogs-dudu closed 6 years ago
This is at best a partial fix, it still wouldn't work for chunked requests. The end to end still needs more thought.
I don't think this is the right place to fix your problem. It only addresses the Content-Length scenario and it makes Content-Length and Chunked behave differently for everybody else. I expect you'd be better of creating a custom HttpContent object that managed this for you.
Address dotnet/corefx#31866
Before FileBufferingReadStream is first read, it's length is not properly set. Before StreamContent is read, it's inner stream length is used to compute ContentLength. When they get together in HttpClient, an http request with misleading
Content-Length: 0
is produced.This PR introduces
_innerLength
to return the length of inner stream before FileBufferingReadStream is first read.