|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
WebRequest and Range HeaderI'm building an application that can download resources using HTTP. In order to enable resuming broken download, I'd like to send to the server some Http Headers : string uriString = "http://server/app/resource.ext"; WebRequest req = WebRequest.Create( uriString ); req.Headers[HttpRequestHeader.IfRange] = ETag; req.Headers["Range"] = "1254-"; This code is supposed to resume the download after the 1254th byte. This code throw an exception when setting the Range header. After some investigations I found the Range headers is blocked within the .Net framework. Firstly, why this header is blocked by the system ? Then, how can I fix this header ? Thanks in advance Steve Thus wrote Steve B.,
Show quote > Hi, There are a number of HTTP headers that are either set through properties > > I'm building an application that can download resources using HTTP. > > In order to enable resuming broken download, I'd like to send to the > server some Http Headers : > > string uriString = "http://server/app/resource.ext"; > > WebRequest req = WebRequest.Create( > > uriString > > ); > > req.Headers[HttpRequestHeader.IfRange] = ETag; > > req.Headers["Range"] = "1254-"; > > This code is supposed to resume the download after the 1254th byte. > > This code throw an exception when setting the Range header. After some > investigations I found the Range headers is blocked within the .Net > framework. > > Firstly, why this header is blocked by the system ? or methods. Setting one of these headers through the Headers collection isn't allowed. > Then, how can I fix this header ? Use one of the HttpWebRequest.AddRange() overloads. Cheers, -- Joerg Jooss news-re***@joergjooss.de I've already tryed all possible code for setting the header.
All of methods use the internal Set method in which the check is applied... Thanks, Steve "Joerg Jooss" <news-re***@joergjooss.de> a écrit dans le message de news: 94fc50712129a8c822b17fe91***@msnews.microsoft.com...Show quote > Thus wrote Steve B., > >> Hi, >> >> I'm building an application that can download resources using HTTP. >> >> In order to enable resuming broken download, I'd like to send to the >> server some Http Headers : >> >> string uriString = "http://server/app/resource.ext"; >> >> WebRequest req = WebRequest.Create( >> >> uriString >> >> ); >> >> req.Headers[HttpRequestHeader.IfRange] = ETag; >> >> req.Headers["Range"] = "1254-"; >> >> This code is supposed to resume the download after the 1254th byte. >> >> This code throw an exception when setting the Range header. After some >> investigations I found the Range headers is blocked within the .Net >> framework. >> >> Firstly, why this header is blocked by the system ? > > There are a number of HTTP headers that are either set through properties > or methods. Setting one of these headers through the Headers collection > isn't allowed. > >> Then, how can I fix this header ? > > Use one of the HttpWebRequest.AddRange() overloads. > Cheers, > -- > Joerg Jooss > news-re***@joergjooss.de > > Still no answer ? :(
"Steve b." <steve_bea***@com.msn.swap.dotcom.and.msn> a écrit dans le message de news: OR1UokMVGHA.4***@TK2MSFTNGP10.phx.gbl...Show quote > I've already tryed all possible code for setting the header. > All of methods use the internal Set method in which the check is > applied... > > Thanks, > Steve > > "Joerg Jooss" <news-re***@joergjooss.de> a écrit dans le message de news: > 94fc50712129a8c822b17fe91***@msnews.microsoft.com... >> Thus wrote Steve B., >> >>> Hi, >>> >>> I'm building an application that can download resources using HTTP. >>> >>> In order to enable resuming broken download, I'd like to send to the >>> server some Http Headers : >>> >>> string uriString = "http://server/app/resource.ext"; >>> >>> WebRequest req = WebRequest.Create( >>> >>> uriString >>> >>> ); >>> >>> req.Headers[HttpRequestHeader.IfRange] = ETag; >>> >>> req.Headers["Range"] = "1254-"; >>> >>> This code is supposed to resume the download after the 1254th byte. >>> >>> This code throw an exception when setting the Range header. After some >>> investigations I found the Range headers is blocked within the .Net >>> framework. >>> >>> Firstly, why this header is blocked by the system ? >> >> There are a number of HTTP headers that are either set through properties >> or methods. Setting one of these headers through the Headers collection >> isn't allowed. >> >>> Then, how can I fix this header ? >> >> Use one of the HttpWebRequest.AddRange() overloads. >> Cheers, >> -- >> Joerg Jooss >> news-re***@joergjooss.de >> >> > > Thus wrote Steve B.,
> Still no answer ? :( Now I'm confused... what about "Use one of the HttpWebRequest.AddRange() overloads". Doesn't that work for you? Cheers, -- Joerg Jooss news-re***@joergjooss.de Sorry, I've not well understand your answer.
Since I was working on a WebRequest and not on a HttpWebRequest I did not see the .AddRange method. I thought you talk about the req.Headers.AddRange (which does not exists :) ) Thanks a lot, I'll try this method.But what about downloads that are not Http ? Thanks, Steve "Joerg Jooss" <news-re***@joergjooss.de> a écrit dans le message de news: 94fc5071225318c8265573865***@msnews.microsoft.com...Show quote > Thus wrote Steve B., > >> Still no answer ? :( > > Now I'm confused... what about "Use one of the HttpWebRequest.AddRange() > overloads". Doesn't that work for you? > > Cheers, > -- > Joerg Jooss > news-re***@joergjooss.de > > Thus wrote Steve B.,
> Sorry, I've not well understand your answer. Sorry, I missed the pure WebRequest part and implied HTTP by default. > > Since I was working on a WebRequest and not on a HttpWebRequest I did > not > see the .AddRange method. > I thought you talk about the req.Headers.AddRange (which does not > exists > :) ) > Thanks a lot, I'll try this method. > > But what about downloads that are not Http ? Range requests are a HTTP feature. I don't know if there's a similar feature in FTP. Cheers, -- Joerg Jooss news-re***@joergjooss.de |
|||||||||||||||||||||||