I'm trying to understand whether I'm missing something or whether it's a limitation in HttpWebRequest setting the TransferEncoding value to chunked.
The below code works perfectly fine, as long as I set the SendChunked
to true
before I set the TransferEncoding value
var httpWebRequest1 = (System.Net.HttpWebRequest)WebRequest.Create("https://SomeApiHost.com/api/v1");
httpWebRequest1.SendChunked = true;
httpWebRequest1.TransferEncoding = "gzip";
however if I attempt the following:
var httpWebRequest2 = (System.Net.HttpWebRequest)WebRequest.Create("https://SomeApiHost.com/api/v1");
httpWebRequest2.SendChunked = true;
httpWebRequest2.TransferEncoding = "Chunked";
I always get this exception
Chunked encoding must be set via the SendChunked property. Parameter name: value
Using HttpClient works fine with the Chunked value, however I can't switch over to it as the RestSharp library uses HttpWebRequest
var client1 = new System.Net.Http.HttpClient()
client1.DefaultRequestHeaders.TryAddWithoutValidation("Transfer-Encoding", "chunked");
client1.DefaultRequestHeaders.TransferEncodingChunked = true;
Does anyone know how to send the Chunked
value in TransferEncoding
with HttpWebReques?