c# - set range on HttpWebRequest headers in Metro App -


i working on windows store app , try set value range header on httpwebrequest can't figure out how this. 3 solutions tried don't work (exceptions or method/property doesn't exist if in msdn documentation).

//create request.         httpwebrequest getrequest = webrequest.create(download.uri) httpwebrequest;          // set request's method.         getrequest.method = "get";          //set range'value on header         /*(1)*/ getrequest.headers[httprequestheader.range] = "bytes="+download.downloadedbytes+"-";         /*(2)*/ getrequest.headers.range = new rangeheadervalue(download.downloadedbytes,null);         /*(3)*/ getrequest.headers.addrange(download.downloadedbytes); 

i know httpwebrequest has semi-deprecated status don't want use httpclient class. not glad of how retrieve error code when http request failed.

does have idea?

in initial header

getrequest.headers[httprequestheader.range] = "bytes="+download.downloadedbytes+"-"; 

i'm not sure value download.downloadedbytes, don't believe string satisfy range field header. string should of form "bytes=500-999"

i've not made work httpwebrequest, can offer sample httpclient (sorry, know don't want switch this, might best)

var client = new httpclient(handler); client.defaultrequestheaders.add("range", @"bytes=0-9000"); var response = await client.getasync(url); 

of course, should noted not web servers respect range header. luck!


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -