If I remember correctly HttpClient naturally buffers the content if you try and read something out of the Content property. In client code you can get around it by using the Content.CopyToAsync. However in yoru case you need to wrap up the reading of request
Content in a new HttpContent without actually reading the stream. I think you would be able to do this with Henrik's ActionofStreamContent class. http://blogs.msdn.com/b/henrikn/archive/2012/02/17/push-and-pull-streams-using-httpclient.aspx
In the lambda you pass to the ActionOfStreamContent constructor you would do a CopyAsync from the request.Content into the new request.Content that you send to the origin server.
Darrel Mille...
Member
176 Points
56 Posts
Re: HttpClient buffering when POSTing data
Apr 17, 2012 05:21 PM|LINK
If I remember correctly HttpClient naturally buffers the content if you try and read something out of the Content property. In client code you can get around it by using the Content.CopyToAsync. However in yoru case you need to wrap up the reading of request Content in a new HttpContent without actually reading the stream. I think you would be able to do this with Henrik's ActionofStreamContent class. http://blogs.msdn.com/b/henrikn/archive/2012/02/17/push-and-pull-streams-using-httpclient.aspx
In the lambda you pass to the ActionOfStreamContent constructor you would do a CopyAsync from the request.Content into the new request.Content that you send to the origin server.