Home All Groups Group Topic Archive Search About

WebRequest and Range Header

Author
31 Mar 2006 5:00 AM
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 ?

Then, how can I fix this header ?



Thanks in advance

Steve

Author
31 Mar 2006 6:08 AM
Joerg Jooss
Thus wrote Steve B.,

Show quote
> 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
Author
31 Mar 2006 1:41 PM
Steve b.
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
>
>
Author
4 Apr 2006 7:30 AM
Steve B.
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
>>
>>
>
>
Author
4 Apr 2006 9:20 PM
Joerg Jooss
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
Author
5 Apr 2006 7:33 AM
Steve B.
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
>
>
Author
6 Apr 2006 6:09 PM
Joerg Jooss
Thus wrote Steve B.,

> 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 ?

Sorry, I missed the pure WebRequest part and implied HTTP by default.

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

AddThis Social Bookmark Button