Unit of Range header changes when sent to server


If I create a request and use HttpClient to send to a server, value of the Unit changes to "bytes" regardless of the value set:

request = new HttpRequestMessage(HttpMethod.Get, "http://localhost:50714/api/Car"); request.Headers.Range = new RangeHeaderValue(1, 2) { Unit = "foo" };
httpResponseMessage = httpClient.SendAsync(request).Result;

Server always gets "bytes" as unit. On client, however, value showing as correct value.
Closed Oct 29, 2013 at 6:58 AM by yishaigalatzer
Thanks for reporting this.

We forwarded your concern to the appropriate team (HttpClient is not part of this project).

It should already work in .NET 4.5, and we are expecting them to fix for 4.0, though since we don't own this area we can guarantee that 100% :)


HongmeiG wrote Aug 10, 2012 at 11:04 PM

Can you send a complete standalone repro for this issue? Web API does not special case RangeHeaderValue. it is up to the server developer how to use this.

Tratcher wrote Oct 17, 2013 at 4:36 PM

You're using the 4.0 version of HttpClient, correct?

It drops the 'Unit' field during a headers copy.

We'll have to get that fixed.

aliostad wrote Oct 17, 2013 at 5:50 PM

Thanks for the attention.